Fixed #7007 (ValueFlow: value is not known, modified by subfunction)

This commit is contained in:
Daniel Marjamäki 2015-11-12 14:59:35 +01:00
parent cf9f12130a
commit 4ec333dbb6
2 changed files with 12 additions and 5 deletions

View File

@ -288,11 +288,9 @@ bool isVariableChanged(const Token *start, const Token *end, const unsigned int
const Token *parent = tok->astParent();
while (parent && parent->str() == ",")
parent = parent->astParent();
if (parent && parent->str() == "(") {
if (parent->astOperand1() && parent->astOperand1()->isName() && !parent->astOperand1()->function())
return true;
// TODO: check if function parameter is non-const reference etc..
}
if (parent && Token::Match(parent->previous(), "%name% (") && !parent->previous()->function())
return true;
// TODO: check if function parameter is non-const reference etc..
}
const Token *parent = tok->astParent();

View File

@ -1692,6 +1692,15 @@ private:
"}\n";
ASSERT(isNotKnownValues(code, "<"));
code = "void f() {\n"
" int x = 0;\n"
" do {\n"
" if (x < 0) {}\n"
" fred.dostuff(x);\n"
" } while (abc);\n"
"}\n";
ASSERT(isNotKnownValues(code, "<"));
code = "void f() {\n"
" int x = 0;\n"
" if (y) { dostuff(x); }\n"