ValueFlow: isVariableChanged() should return true when variable is changed by passing its address to subfunction

This commit is contained in:
Daniel Marjamäki 2015-07-18 15:35:39 +02:00
parent 5aa0b284dc
commit ce7e879460
2 changed files with 4 additions and 1 deletions

View File

@ -276,6 +276,9 @@ static bool isVariableChanged(const Token *start, const Token *end, const unsign
if (Token::Match(tok, "%name% ="))
return true;
if (Token::Match(tok->tokAt(-2), "[(,] & %var% [,)]"))
return true; // TODO: check if function parameter is const
const Token *parent = tok->astParent();
while (Token::Match(parent, ".|::"))
parent = parent->astParent();

View File

@ -1572,7 +1572,7 @@ private:
code = "void f() {\n"
" int x = 0;\n"
" while (!x) {\n" // <- possible value
" x = dostuff();\n"
" scanf(\"%d\", &x);\n"
" }\n"
"}";
value = valueOfTok(code, "!");