ValueFlow: Improved handling of alias values in valueFlowForward
This commit is contained in:
parent
1d873de67f
commit
8a1b8df1ba
|
@ -142,6 +142,8 @@ static std::map<unsigned int, MathLib::bigint> getProgramMemory(const Token *tok
|
||||||
{
|
{
|
||||||
std::map<unsigned int, MathLib::bigint> programMemory;
|
std::map<unsigned int, MathLib::bigint> programMemory;
|
||||||
programMemory[varid] = value.intvalue;
|
programMemory[varid] = value.intvalue;
|
||||||
|
if (value.varId)
|
||||||
|
programMemory[value.varId] = value.varvalue;
|
||||||
const std::map<unsigned int, MathLib::bigint> programMemory1(programMemory);
|
const std::map<unsigned int, MathLib::bigint> programMemory1(programMemory);
|
||||||
int indentlevel = 0;
|
int indentlevel = 0;
|
||||||
for (const Token *tok2 = tok; tok2; tok2 = tok2->previous()) {
|
for (const Token *tok2 = tok; tok2; tok2 = tok2->previous()) {
|
||||||
|
|
|
@ -766,6 +766,13 @@ private:
|
||||||
"}";
|
"}";
|
||||||
ASSERT_EQUALS(false, testValueOfX(code, 6U, 0));
|
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"
|
code = "void f () {\n"
|
||||||
" ST * x = g_pST;\n"
|
" ST * x = g_pST;\n"
|
||||||
" if (x->y == 0) {\n"
|
" if (x->y == 0) {\n"
|
||||||
|
|
Loading…
Reference in New Issue