ValueFlow: Improved handling of alias values in valueFlowForward

This commit is contained in:
Daniel Marjamäki 2015-02-08 19:20:05 +01:00
parent 1d873de67f
commit 8a1b8df1ba
2 changed files with 9 additions and 0 deletions

View File

@ -142,6 +142,8 @@ static std::map<unsigned int, MathLib::bigint> getProgramMemory(const Token *tok
{
std::map<unsigned int, MathLib::bigint> programMemory;
programMemory[varid] = value.intvalue;
if (value.varId)
programMemory[value.varId] = value.varvalue;
const std::map<unsigned int, MathLib::bigint> programMemory1(programMemory);
int indentlevel = 0;
for (const Token *tok2 = tok; tok2; tok2 = tok2->previous()) {

View File

@ -766,6 +766,13 @@ private:
"}";
ASSERT_EQUALS(false, testValueOfX(code, 6U, 0));
code = "void f(int y) {\n" // alias
" int x = y;\n"
" if (y == 54) {}\n"
" else { a = x; }\n"
"}";
ASSERT_EQUALS(false, testValueOfX(code, 4U, 54));
code = "void f () {\n"
" ST * x = g_pST;\n"
" if (x->y == 0) {\n"