Fixed #7363 (valueflowOppositeCondition - if (size1 > size2) ... else if (size1 < size2) ...)
This commit is contained in:
parent
3b046b42a6
commit
d5884692df
|
@ -733,7 +733,7 @@ static void valueFlowOppositeCondition(SymbolDatabase *symboldatabase, const Set
|
||||||
const Token *cond2 = tok2->tokAt(4)->astOperand2();
|
const Token *cond2 = tok2->tokAt(4)->astOperand2();
|
||||||
if (!cond2 || !cond2->isComparisonOp())
|
if (!cond2 || !cond2->isComparisonOp())
|
||||||
continue;
|
continue;
|
||||||
if (isOppositeCond(false, cpp, cond1, cond2, settings->library.functionpure)) {
|
if (isOppositeCond(true, cpp, cond1, cond2, settings->library.functionpure)) {
|
||||||
ValueFlow::Value value(1);
|
ValueFlow::Value value(1);
|
||||||
value.setKnown();
|
value.setKnown();
|
||||||
setTokenValue(const_cast<Token*>(cond2), value);
|
setTokenValue(const_cast<Token*>(cond2), value);
|
||||||
|
|
|
@ -1897,6 +1897,12 @@ private:
|
||||||
ASSERT_EQUALS(1, value.intvalue);
|
ASSERT_EQUALS(1, value.intvalue);
|
||||||
ASSERT(value.isKnown());
|
ASSERT(value.isKnown());
|
||||||
|
|
||||||
|
code = "int f(int x) {\n"
|
||||||
|
" if (x < 2) {}\n"
|
||||||
|
" else if (x > 2) {}\n" // <- possible value
|
||||||
|
"}";
|
||||||
|
ASSERT(isNotKnownValues(code, ">"));
|
||||||
|
|
||||||
// function
|
// function
|
||||||
code = "int f(int x) { return x + 1; }\n" // <- possible value
|
code = "int f(int x) { return x + 1; }\n" // <- possible value
|
||||||
"void a() { f(12); }\b";
|
"void a() { f(12); }\b";
|
||||||
|
|
Loading…
Reference in New Issue