Fixed ticket #3309 (false positive: (style) Boolean result is used in bitwise operation. Clarify expression with parentheses)
This commit is contained in:
parent
8a60ceed82
commit
0569953753
|
@ -7243,8 +7243,8 @@ bool Tokenizer::simplifyRedundantParenthesis()
|
|||
continue;
|
||||
}
|
||||
|
||||
if (Token::Match(tok->previous(), "(|[|,|! ( %var% %op% %var% ) ,|]|)") ||
|
||||
Token::Match(tok->previous(), "(|[|,|! ( %var% %op% %num% ) ,|]|)")) {
|
||||
if (Token::Match(tok->previous(), "(|[|,| ( %var% %op% %var% ) ,|]|)") ||
|
||||
Token::Match(tok->previous(), "(|[|,| ( %var% %op% %num% ) ,|]|)")) {
|
||||
// We have "( var %op% var )", remove the parenthesis
|
||||
tok->deleteThis();
|
||||
tok = tok->tokAt(2);
|
||||
|
|
|
@ -241,6 +241,7 @@ private:
|
|||
TEST_CASE(removeParentheses11); // Ticket #2505
|
||||
TEST_CASE(removeParentheses12); // Ticket #2760 ',(b)='
|
||||
TEST_CASE(removeParentheses13);
|
||||
TEST_CASE(removeParentheses14); // Ticket #3309
|
||||
|
||||
TEST_CASE(tokenize_double);
|
||||
TEST_CASE(tokenize_strings);
|
||||
|
@ -3969,6 +3970,10 @@ private:
|
|||
ASSERT_EQUALS("; x = y [ a + b ] ;", tokenizeAndStringify(";x=y[(a+b)];", false));
|
||||
}
|
||||
|
||||
void removeParentheses14() {
|
||||
ASSERT_EQUALS("; if ( ! ( i & 1 ) ) { ; } ;", tokenizeAndStringify("; if ( (a & b) == 0 ); ;", false));
|
||||
}
|
||||
|
||||
void tokenize_double() {
|
||||
const char code[] = "void f()\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue