Skip to content

Commit a14accb

Browse files
committed
Translate if constexpr
1 parent c16760d commit a14accb

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

‎cpp2rust/converter/converter.cpp‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,15 @@ void Converter::ConvertCondition(clang::Expr *cond) {
13561356
}
13571357

13581358
bool Converter::VisitIfStmt(clang::IfStmt *stmt) {
1359+
if (stmt->isConstexpr()) {
1360+
if (auto taken = stmt->getNondiscardedCase(ctx_)) {
1361+
if (*taken) {
1362+
Convert(*taken);
1363+
}
1364+
return false;
1365+
}
1366+
}
1367+
13591368
if (auto *init = stmt->getInit()) {
13601369
PushBrace scope(*this);
13611370
Convert(init);

‎cpp2rust/converter/converter.h‎

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

426426
virtual bool VisitTypeTraitExpr(clang::TypeTraitExpr *expr);
427+
427428
virtual bool VisitSizeOfPackExpr(clang::SizeOfPackExpr *expr);
428429

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

0 commit comments

Comments
 (0)