Fix issue 9709: ValueFlow: variable value is not known (#2643)
This commit is contained in:
parent
4afaff059b
commit
d123279fc1
|
@ -199,6 +199,10 @@ static void fillProgramMemoryFromAssignments(ProgramMemory& pm, const Token* tok
|
||||||
else
|
else
|
||||||
pm.setUnknown(vartok->varId());
|
pm.setUnknown(vartok->varId());
|
||||||
}
|
}
|
||||||
|
} else if (!setvar && Token::Match(tok2, "%var% !!=") && isVariableChanged(tok2, 0, nullptr, true)) {
|
||||||
|
const Token *vartok = tok2;
|
||||||
|
if (!pm.hasValue(vartok->varId()))
|
||||||
|
pm.setUnknown(vartok->varId());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tok2->str() == "{") {
|
if (tok2->str() == "{") {
|
||||||
|
|
|
@ -3366,6 +3366,18 @@ private:
|
||||||
" if (!x) {}\n"
|
" if (!x) {}\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// #9709
|
||||||
|
check("void f(int a) {\n"
|
||||||
|
" bool ok = false;\n"
|
||||||
|
" const char * r = nullptr;\n"
|
||||||
|
" do_something(&r);\n"
|
||||||
|
" if (r != nullptr)\n"
|
||||||
|
" ok = a != 0;\n"
|
||||||
|
" if (ok) {}\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void alwaysTrueInfer() {
|
void alwaysTrueInfer() {
|
||||||
|
|
Loading…
Reference in New Issue