Fix FP for symbolic values when the expression is not const (#3370)

This commit is contained in:
Paul Fultz II 2021-07-31 07:19:37 -05:00 committed by GitHub
parent 3a7ba3cd29
commit 6767b57d4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -4018,6 +4018,8 @@ static void valueFlowSymbolic(TokenList* tokenlist, SymbolDatabase* symboldataba
continue;
if (tok->astOperand2()->hasKnownIntValue())
continue;
if (!isConstExpression(tok->astOperand2(), tokenlist->getSettings()->library, true, tokenlist->isCPP()))
continue;
Token* start = nextAfterAstRightmostLeaf(tok);
const Token* end = scope->bodyEnd;

View File

@ -5998,6 +5998,13 @@ private:
" return x;\n"
"}\n";
ASSERT_EQUALS(true, testValueOfXKnown(code, 5U, 1));
code = "int f(int i) {\n"
" int j = i++;\n"
" int x = i++;\n"
" return x;\n"
"}\n";
ASSERT_EQUALS(false, testValueOfXKnown(code, 4U, "i++", 0));
}
};