Fix 10354: FP knownConditionTrueFalse after bitwise and/xor (#3360)
This commit is contained in:
parent
0d3afbb954
commit
c34691ff56
|
@ -1533,7 +1533,7 @@ static std::vector<MathLib::bigint> minUnsignedValue(const Token* tok, int depth
|
|||
return result;
|
||||
if (tok->hasKnownIntValue()) {
|
||||
result = {tok->values().front().intvalue};
|
||||
} else if (!Token::Match(tok, "-|%") && tok->isConstOp() && tok->astOperand1() && tok->astOperand2()) {
|
||||
} else if (!Token::Match(tok, "-|%|&|^") && tok->isConstOp() && tok->astOperand1() && tok->astOperand2()) {
|
||||
std::vector<MathLib::bigint> op1 = minUnsignedValue(tok->astOperand1(), depth - 1);
|
||||
std::vector<MathLib::bigint> op2 = minUnsignedValue(tok->astOperand2(), depth - 1);
|
||||
if (!op1.empty() && !op2.empty()) {
|
||||
|
|
|
@ -5866,6 +5866,20 @@ private:
|
|||
"}\n";
|
||||
ASSERT_EQUALS(false, testValueOfXImpossible(code, 3U, 0));
|
||||
ASSERT_EQUALS(true, testValueOfXImpossible(code, 3U, -1));
|
||||
|
||||
code = "auto f(uint32_t i) {\n"
|
||||
" auto x = i ^ 3;\n"
|
||||
" return x;\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS(false, testValueOfXImpossible(code, 3U, 2));
|
||||
ASSERT_EQUALS(true, testValueOfXImpossible(code, 3U, -1));
|
||||
|
||||
code = "auto f(uint32_t i) {\n"
|
||||
" auto x = i & 3;\n"
|
||||
" return x;\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS(false, testValueOfXImpossible(code, 3U, 2));
|
||||
ASSERT_EQUALS(true, testValueOfXImpossible(code, 3U, -1));
|
||||
}
|
||||
|
||||
void valueFlowMod() {
|
||||
|
|
Loading…
Reference in New Issue