ValueFlow: Refactoring. Use utility function isVariableChanged.

This commit is contained in:
Daniel Marjamäki 2014-06-19 05:41:19 +02:00
parent e8f0da845b
commit dec251ac44
2 changed files with 2 additions and 14 deletions

View File

@ -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>

View File

@ -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;