@@ -5051,7 +5051,7 @@ template <class Emitter> bool Compiler<Emitter>::visitStmt(const Stmt *S) {
50515051 case Stmt::CompoundStmtClass:
50525052 return visitCompoundStmt (cast<CompoundStmt>(S));
50535053 case Stmt::DeclStmtClass:
5054- return visitDeclStmt (cast<DeclStmt>(S));
5054+ return visitDeclStmt (cast<DeclStmt>(S), /* EvaluateConditionDecl= */ true );
50555055 case Stmt::ReturnStmtClass:
50565056 return visitReturnStmt (cast<ReturnStmt>(S));
50575057 case Stmt::IfStmtClass:
@@ -5115,7 +5115,8 @@ bool Compiler<Emitter>::emitDecompositionVarInit(const DecompositionDecl *DD) {
51155115}
51165116
51175117template <class Emitter >
5118- bool Compiler<Emitter>::visitDeclStmt(const DeclStmt *DS) {
5118+ bool Compiler<Emitter>::visitDeclStmt(const DeclStmt *DS,
5119+ bool EvaluateConditionDecl) {
51195120 for (const auto *D : DS->decls ()) {
51205121 if (isa<StaticAssertDecl, TagDecl, TypedefNameDecl, BaseUsingDecl,
51215122 FunctionDecl, NamespaceAliasDecl, UsingDirectiveDecl>(D))
@@ -5129,7 +5130,7 @@ bool Compiler<Emitter>::visitDeclStmt(const DeclStmt *DS) {
51295130
51305131 // Register decomposition decl holding vars.
51315132 if (const auto *DD = dyn_cast<DecompositionDecl>(VD);
5132- DD && !DD-> isDecisionVariable () ) {
5133+ EvaluateConditionDecl && DD ) {
51335134 if (!this ->emitDecompositionVarInit (DD))
51345135 return false ;
51355136 }
@@ -5180,7 +5181,7 @@ template <class Emitter> bool Compiler<Emitter>::visitIfStmt(const IfStmt *IS) {
51805181 return false ;
51815182
51825183 if (const DeclStmt *CondDecl = IS->getConditionVariableDeclStmt ())
5183- if (!visitDeclStmt (CondDecl))
5184+ if (!visitDeclStmt (CondDecl, /* EvaluateConditionDecl= */ false ))
51845185 return false ;
51855186
51865187 // Compile condition.
@@ -5198,8 +5199,7 @@ template <class Emitter> bool Compiler<Emitter>::visitIfStmt(const IfStmt *IS) {
51985199 }
51995200
52005201 if (auto *DD =
5201- dyn_cast_if_present<DecompositionDecl>(IS->getConditionVariable ());
5202- DD && DD->isDecisionVariable ())
5202+ dyn_cast_if_present<DecompositionDecl>(IS->getConditionVariable ()))
52035203 if (!this ->emitDecompositionVarInit (DD))
52045204 return false ;
52055205
@@ -5258,15 +5258,14 @@ bool Compiler<Emitter>::visitWhileStmt(const WhileStmt *S) {
52585258 {
52595259 LocalScope<Emitter> CondScope (this );
52605260 if (const DeclStmt *CondDecl = S->getConditionVariableDeclStmt ())
5261- if (!visitDeclStmt (CondDecl))
5261+ if (!visitDeclStmt (CondDecl, /* EvaluateConditionDecl= */ false ))
52625262 return false ;
52635263
52645264 if (!this ->visitBool (Cond))
52655265 return false ;
52665266
52675267 if (auto *DD =
5268- dyn_cast_if_present<DecompositionDecl>(S->getConditionVariable ());
5269- DD && DD->isDecisionVariable ())
5268+ dyn_cast_if_present<DecompositionDecl>(S->getConditionVariable ()))
52705269 if (!this ->emitDecompositionVarInit (DD))
52715270 return false ;
52725271
@@ -5341,7 +5340,7 @@ bool Compiler<Emitter>::visitForStmt(const ForStmt *S) {
53415340 {
53425341 LocalScope<Emitter> CondScope (this );
53435342 if (const DeclStmt *CondDecl = S->getConditionVariableDeclStmt ())
5344- if (!visitDeclStmt (CondDecl))
5343+ if (!visitDeclStmt (CondDecl, /* EvaluateConditionDecl= */ false ))
53455344 return false ;
53465345
53475346 if (Cond) {
@@ -5352,8 +5351,7 @@ bool Compiler<Emitter>::visitForStmt(const ForStmt *S) {
53525351 }
53535352
53545353 if (auto *DD =
5355- dyn_cast_if_present<DecompositionDecl>(S->getConditionVariable ());
5356- DD && DD->isDecisionVariable ())
5354+ dyn_cast_if_present<DecompositionDecl>(S->getConditionVariable ()))
53575355 if (!this ->emitDecompositionVarInit (DD))
53585356 return false ;
53595357
@@ -5470,7 +5468,7 @@ bool Compiler<Emitter>::visitSwitchStmt(const SwitchStmt *S) {
54705468 return false ;
54715469
54725470 if (const DeclStmt *CondDecl = S->getConditionVariableDeclStmt ())
5473- if (!visitDeclStmt (CondDecl))
5471+ if (!visitDeclStmt (CondDecl, /* EvaluateConditionDecl= */ false ))
54745472 return false ;
54755473
54765474 // Initialize condition variable.
@@ -5480,8 +5478,7 @@ bool Compiler<Emitter>::visitSwitchStmt(const SwitchStmt *S) {
54805478 return false ;
54815479
54825480 if (auto *DD =
5483- dyn_cast_if_present<DecompositionDecl>(S->getConditionVariable ());
5484- DD && DD->isDecisionVariable ())
5481+ dyn_cast_if_present<DecompositionDecl>(S->getConditionVariable ()))
54855482 if (!this ->emitDecompositionVarInit (DD))
54865483 return false ;
54875484
0 commit comments