Skip to content

Commit d7054bc

Browse files
committed
Translate if constexpr
1 parent 24703cc commit d7054bc

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

‎cpp2rust/converter/converter.cpp‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,14 @@ void Converter::ConvertCondition(clang::Expr *cond) {
12541254
}
12551255

12561256
bool Converter::VisitIfStmt(clang::IfStmt *stmt) {
1257+
if (stmt->isConstexpr()) {
1258+
if (auto taken = stmt->getNondiscardedCase(ctx_)) {
1259+
if (*taken) {
1260+
Convert(*taken);
1261+
}
1262+
return false;
1263+
}
1264+
}
12571265
StrCat(keyword::kIf);
12581266
ConvertCondition(stmt->getCond());
12591267
ConvertBody(stmt->getThen());

‎cpp2rust/converter/converter.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ class Converter : public clang::RecursiveASTVisitor<Converter> {
405405
VisitUnaryExprOrTypeTraitExpr(clang::UnaryExprOrTypeTraitExpr *expr);
406406

407407
virtual bool VisitTypeTraitExpr(clang::TypeTraitExpr *expr);
408+
408409
virtual bool VisitSizeOfPackExpr(clang::SizeOfPackExpr *expr);
409410

410411
virtual bool VisitOffsetOfExpr(clang::OffsetOfExpr *expr);

0 commit comments

Comments
 (0)