Fix issue 10111: FP knownConditionTrueFalse (#3110)
This commit is contained in:
parent
b003c82650
commit
cf8a5d9a22
|
@ -440,7 +440,11 @@ static void setTokenValue(Token* tok, const ValueFlow::Value &value, const Setti
|
|||
// .empty, .size, +"abc", +'a'
|
||||
if (Token::Match(parent, "+|==|!=") && parent->astOperand1() && parent->astOperand2()) {
|
||||
for (const ValueFlow::Value &value1 : parent->astOperand1()->values()) {
|
||||
if (value1.isImpossible())
|
||||
continue;
|
||||
for (const ValueFlow::Value &value2 : parent->astOperand2()->values()) {
|
||||
if (value2.isImpossible())
|
||||
continue;
|
||||
if (value1.path != value2.path)
|
||||
continue;
|
||||
ValueFlow::Value result;
|
||||
|
|
|
@ -5026,6 +5026,17 @@ private:
|
|||
"}\n";
|
||||
ASSERT_EQUALS(true, testValueOfXKnown(code, 4U, 0));
|
||||
|
||||
code = "bool f(std::string s) {\n"
|
||||
" if (!s.empty()) {\n"
|
||||
" bool x = s == \"0\";\n"
|
||||
" return x;\n"
|
||||
" }\n"
|
||||
" return false;\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS(false, testValueOfXKnown(code, 4U, 0));
|
||||
ASSERT_EQUALS(false, testValueOfXKnown(code, 4U, 1));
|
||||
ASSERT_EQUALS(false, testValueOfXImpossible(code, 4U, 0));
|
||||
|
||||
code = "std::vector<int> g();\n"
|
||||
"int f(bool b) {\n"
|
||||
" std::set<int> a;\n"
|
||||
|
|
Loading…
Reference in New Issue