| 410 | } |
| 411 | |
| 412 | bool reentersLoop(Token* endBlock, const Token* condTok, const Token* stepTok) const { |
| 413 | if (!condTok) |
| 414 | return true; |
| 415 | if (Token::simpleMatch(condTok, ":")) |
| 416 | return true; |
| 417 | bool stepChangesCond = false; |
| 418 | if (stepTok) { |
| 419 | std::pair<const Token*, const Token*> exprToks = stepTok->findExpressionStartEndTokens(); |
| 420 | if (exprToks.first != nullptr && exprToks.second != nullptr) |
| 421 | stepChangesCond |= |
| 422 | findExpressionChanged(condTok, exprToks.first, exprToks.second->next(), settings) != nullptr; |
| 423 | } |
| 424 | const bool bodyChangesCond = findExpressionChanged(condTok, endBlock->link(), endBlock, settings); |
| 425 | // Check for mutation in the condition |
| 426 | const bool condChanged = |
| 427 | nullptr != findAstNode(condTok, [&](const Token* tok) { |
| 428 | return isVariableChanged(tok, 0, settings); |
| 429 | }); |
| 430 | const bool changed = stepChangesCond || bodyChangesCond || condChanged; |
| 431 | if (!changed) |
| 432 | return true; |
| 433 | ForwardTraversal ft = fork(true); |
| 434 | ft.updateScope(endBlock); |
| 435 | return ft.isConditionTrue(condTok) && bodyChangesCond; |
| 436 | } |
| 437 | |
| 438 | Progress updateInnerLoop(Token* endBlock, Token* stepTok, Token* condTok) { |
| 439 | loopEnds.push_back(endBlock); |
no test coverage detected