[clang-tidy] Fix handling of parentheses in bugprone-non-zero-enum-to-bool-conversion (#81890)
Properly ignore parentheses in bitwise operators. Closes #81515
This commit is contained in:
parent
b366643ca3
commit
75adb12269
@ -64,7 +64,7 @@ void NonZeroEnumToBoolConversionCheck::registerMatchers(MatchFinder *Finder) {
|
||||
EnumIgnoreList)))
|
||||
.bind("enum"))))),
|
||||
unless(declRefExpr(to(enumConstantDecl()))),
|
||||
unless(ignoringImplicit(ExcludedOperators)))),
|
||||
unless(ignoringParenImpCasts(ExcludedOperators)))),
|
||||
unless(hasAncestor(staticAssertDecl())))
|
||||
.bind("cast"),
|
||||
this);
|
||||
|
@ -112,6 +112,11 @@ New check aliases
|
||||
Changes in existing checks
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
- Improved :doc:`bugprone-non-zero-enum-to-bool-conversion
|
||||
<clang-tidy/checks/bugprone/non-zero-enum-to-bool-conversion>` check by
|
||||
eliminating false positives resulting from direct usage of bitwise operators
|
||||
within parentheses.
|
||||
|
||||
- Improved :doc:`bugprone-suspicious-include
|
||||
<clang-tidy/checks/bugprone/suspicious-include>` check by replacing the local
|
||||
options `HeaderFileExtensions` and `ImplementationFileExtensions` by the
|
||||
|
@ -122,6 +122,8 @@ CustomOperatorEnum operator&(CustomOperatorEnum a, CustomOperatorEnum b) { retur
|
||||
|
||||
void testCustomOperator(CustomOperatorEnum e) {
|
||||
if (e & E1) {}
|
||||
if ((e & E1)) {}
|
||||
if (!(e & E1)) {}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user