@@ -913,9 +913,7 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
913913 if (CondConstant)
914914 incrementProfileCounter (&S);
915915 if (Executed) {
916- if (auto *DD = dyn_cast_if_present<DecompositionDecl>(
917- S.getConditionVariable ()))
918- EmitDecompositionVarInit (*DD);
916+ MaybeEmitDeferredVarDeclInit (S.getConditionVariable ());
919917 RunCleanupsScope ExecutedScope (*this );
920918 EmitStmt (Executed);
921919 }
@@ -961,9 +959,7 @@ void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
961959 /* ConditionalDecl=*/ S.getConditionVariable ());
962960 } else {
963961 llvm::Value *BoolCondVal = EvaluateExprAsBool (S.getCond ());
964- if (auto *DD =
965- dyn_cast_if_present<DecompositionDecl>(S.getConditionVariable ()))
966- EmitDecompositionVarInit (*DD);
962+ MaybeEmitDeferredVarDeclInit (S.getConditionVariable ());
967963 Builder.CreateCondBr (BoolCondVal, ThenBlock, ElseBlock);
968964 }
969965
@@ -1107,9 +1103,7 @@ void CodeGenFunction::EmitWhileStmt(const WhileStmt &S,
11071103 // execution of the loop body.
11081104 llvm::Value *BoolCondVal = EvaluateExprAsBool (S.getCond ());
11091105
1110- if (auto *DD =
1111- dyn_cast_if_present<DecompositionDecl>(S.getConditionVariable ()))
1112- EmitDecompositionVarInit (*DD);
1106+ MaybeEmitDeferredVarDeclInit (S.getConditionVariable ());
11131107
11141108 // while(1) is common, avoid extra exit blocks. Be sure
11151109 // to correctly handle break/continue though.
@@ -1345,9 +1339,7 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S,
13451339 // compares unequal to 0. The condition must be a scalar type.
13461340 llvm::Value *BoolCondVal = EvaluateExprAsBool (S.getCond ());
13471341
1348- if (auto *DD =
1349- dyn_cast_if_present<DecompositionDecl>(S.getConditionVariable ()))
1350- EmitDecompositionVarInit (*DD);
1342+ MaybeEmitDeferredVarDeclInit (S.getConditionVariable ());
13511343
13521344 llvm::MDNode *Weights =
13531345 createProfileWeightsForLoop (S.getCond (), getProfileCount (S.getBody ()));
@@ -2244,11 +2236,7 @@ void CodeGenFunction::EmitSwitchStmt(const SwitchStmt &S) {
22442236 // Emit the condition variable if needed inside the entire cleanup scope
22452237 // used by this special case for constant folded switches.
22462238 if (S.getConditionVariable ())
2247- EmitDecl (*S.getConditionVariable ());
2248-
2249- if (auto *DD =
2250- dyn_cast_if_present<DecompositionDecl>(S.getConditionVariable ()))
2251- EmitDecompositionVarInit (*DD);
2239+ EmitDecl (*S.getConditionVariable (), /* EvaluateConditionDecl=*/ true );
22522240
22532241 // At this point, we are no longer "within" a switch instance, so
22542242 // we can temporarily enforce this to ensure that any embedded case
@@ -2280,10 +2268,7 @@ void CodeGenFunction::EmitSwitchStmt(const SwitchStmt &S) {
22802268 if (S.getConditionVariable ())
22812269 EmitDecl (*S.getConditionVariable ());
22822270 llvm::Value *CondV = EmitScalarExpr (S.getCond ());
2283-
2284- if (auto *DD =
2285- dyn_cast_if_present<DecompositionDecl>(S.getConditionVariable ()))
2286- EmitDecompositionVarInit (*DD);
2271+ MaybeEmitDeferredVarDeclInit (S.getConditionVariable ());
22872272
22882273 // Create basic block to hold stuff that comes after switch
22892274 // statement. We also need to create a default block now so that
0 commit comments