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="tanhf" value="tanh"/>
|
||||||
<define name="truncf" value="trunc"/>
|
<define name="truncf" value="trunc"/>
|
||||||
<!-- The rest of the trigonometric functions are defined in std.cfg -->
|
<!-- The rest of the trigonometric functions are defined in std.cfg -->
|
||||||
<!-- setjmp.h -->
|
<!-- setjmp.h -->
|
||||||
</def>
|
</def>
|
||||||
|
|
|
@ -818,19 +818,7 @@ static void valueFlowAfterCondition(TokenList *tokenlist, ErrorLogger *errorLogg
|
||||||
const Token *top = tok->astTop();
|
const Token *top = tok->astTop();
|
||||||
if (top && Token::Match(top->previous(), "if|while (") && !top->previous()->isExpandedMacro()) {
|
if (top && Token::Match(top->previous(), "if|while (") && !top->previous()->isExpandedMacro()) {
|
||||||
// does condition reassign variable?
|
// does condition reassign variable?
|
||||||
std::stack<const Token *> tokens;
|
if (isVariableChanged(top,top->link(),varid)) {
|
||||||
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 (settings->debugwarnings)
|
if (settings->debugwarnings)
|
||||||
bailout(tokenlist, errorLogger, tok, "assignment in condition");
|
bailout(tokenlist, errorLogger, tok, "assignment in condition");
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue