@@ -394,24 +394,24 @@ struct ForwardTraversal {
394394 return true ;
395395 if (Token::simpleMatch (condTok, " :" ))
396396 return true ;
397- bool changed = false ;
397+ bool stepChangesCond = false ;
398398 if (stepTok) {
399399 std::pair<const Token*, const Token*> exprToks = stepTok->findExpressionStartEndTokens ();
400400 if (exprToks.first != nullptr && exprToks.second != nullptr )
401- changed |= isExpressionChanged (condTok, exprToks.first , exprToks.second ->next (), settings, true );
401+ stepChangesCond |= isExpressionChanged (condTok, exprToks.first , exprToks.second ->next (), settings, true );
402402 }
403- changed | = isExpressionChanged (condTok, endBlock->link (), endBlock, settings, true );
403+ const bool bodyChangesCond = isExpressionChanged (condTok, endBlock->link (), endBlock, settings, true );
404404 // Check for mutation in the condition
405- changed |= nullptr ! =
406- findAstNode (condTok, [&](const Token* tok) {
405+ const bool condChanged =
406+ nullptr != findAstNode (condTok, [&](const Token* tok) {
407407 return isVariableChanged (tok, 0 , settings, true );
408408 });
409+ const bool changed = stepChangesCond || bodyChangesCond || condChanged;
409410 if (!changed)
410411 return true ;
411412 ForwardTraversal ft = fork (true );
412- ft.analyzer ->assume (condTok, false , Analyzer::Assume::Absolute);
413413 ft.updateScope (endBlock);
414- return ft.isConditionTrue (condTok);
414+ return ft.isConditionTrue (condTok) && bodyChangesCond ;
415415 }
416416
417417 Progress updateInnerLoop (Token* endBlock, Token* stepTok, Token* condTok) {
0 commit comments