Fixed #6537 (False positive badBitmaskCheck - error in valueflow)
This commit is contained in:
parent
a8416bfb16
commit
6faa637fc7
|
@ -256,8 +256,8 @@ void CheckCondition::checkBadBitmaskCheck()
|
||||||
(parent->str() == "(" && Token::Match(parent->astOperand1(), "if|while")) ||
|
(parent->str() == "(" && Token::Match(parent->astOperand1(), "if|while")) ||
|
||||||
(parent->str() == "return" && parent->astOperand1() == tok && inBooleanFunction(tok));
|
(parent->str() == "return" && parent->astOperand1() == tok && inBooleanFunction(tok));
|
||||||
|
|
||||||
const bool isTrue = (tok->astOperand1()->values.size() == 1 && tok->astOperand1()->values.front().intvalue != 0 && !tok->astOperand1()->values.front().conditional) ||
|
const bool isTrue = (tok->astOperand1()->values.size() == 1 && tok->astOperand1()->values.front().intvalue != 0 && tok->astOperand1()->values.front().isKnown()) ||
|
||||||
(tok->astOperand2()->values.size() == 1 && tok->astOperand2()->values.front().intvalue != 0 && !tok->astOperand2()->values.front().conditional);
|
(tok->astOperand2()->values.size() == 1 && tok->astOperand2()->values.front().intvalue != 0 && tok->astOperand2()->values.front().isKnown());
|
||||||
|
|
||||||
if (isBoolean && isTrue)
|
if (isBoolean && isTrue)
|
||||||
badBitmaskCheckError(tok);
|
badBitmaskCheckError(tok);
|
||||||
|
|
|
@ -581,6 +581,13 @@ private:
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("void f(unsigned a, unsigned b) {\n"
|
||||||
|
" unsigned cmd1 = b & 0x0F;\n"
|
||||||
|
" if (cmd1 | a) {\n"
|
||||||
|
" if (b == 0x0C) {}\n"
|
||||||
|
" }\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue