ValueFlow: Refactoring. Use utility function isVariableChanged.
This commit is contained in:
parent
e8f0da845b
commit
dec251ac44
|
@ -117,5 +117,5 @@
|
|||
<define name="tanhf" value="tanh"/>
|
||||
<define name="truncf" value="trunc"/>
|
||||
<!-- The rest of the trigonometric functions are defined in std.cfg -->
|
||||
<!-- setjmp.h -->
|
||||
<!-- setjmp.h -->
|
||||
</def>
|
||||
|
|
|
@ -818,19 +818,7 @@ static void valueFlowAfterCondition(TokenList *tokenlist, ErrorLogger *errorLogg
|
|||
const Token *top = tok->astTop();
|
||||
if (top && Token::Match(top->previous(), "if|while (") && !top->previous()->isExpandedMacro()) {
|
||||
// does condition reassign variable?
|
||||
std::stack<const Token *> tokens;
|
||||
tokens.push(top);
|
||||
while (!tokens.empty()) {
|
||||
const Token *tok2 = tokens.top();
|
||||
tokens.pop();
|
||||
if (!tok2)
|
||||
continue;
|
||||
tokens.push(tok2->astOperand1());
|
||||
tokens.push(tok2->astOperand2());
|
||||
if (tok2->str() == "=" && Token::Match(tok2->astOperand1(), "%varid%", varid))
|
||||
break;
|
||||
}
|
||||
if (!tokens.empty()) {
|
||||
if (isVariableChanged(top,top->link(),varid)) {
|
||||
if (settings->debugwarnings)
|
||||
bailout(tokenlist, errorLogger, tok, "assignment in condition");
|
||||
continue;
|
||||
|
|
Loading…
Reference in New Issue