We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A slight variation of #65315
enum E { E1 = 1, E2 = 2 }; E operator&(E a, E b) { return static_cast<E>((int)a & (int)b); } void f(E e) { if (!(e & E1)) {} }
[<source>:4:10: warning: conversion of 'E' into 'bool' will always return 'true', enum doesn't have a zero-value enumerator [bugprone-non-zero-enum-to-bool-conversion] 4 | if (!(e & E1)) {} | ^ [<source>:1:6: note: enum is defined here](javascript:;) 1 | enum E { E1 = 1, E2 = 2 }; | ^
https://godbolt.org/z/r1P3zx38a
The text was updated successfully, but these errors were encountered:
Problem is caused by extra (). Fix:
--- a/clang-tools-extra/clang-tidy/bugprone/NonZeroEnumToBoolConversionCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/NonZeroEnumToBoolConversionCheck.cpp @@ -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);
Sorry, something went wrong.
[clang-tidy] Fix handling of parentheses in bugprone-non-zero-enum-to…
3b8defa
…-bool-conversion Properly ignore parentheses in bitwise operators. Closes: llvm#81515
75adb12
…-bool-conversion (#81890) Properly ignore parentheses in bitwise operators. Closes #81515
PiotrZSL
Successfully merging a pull request may close this issue.
A slight variation of #65315
https://godbolt.org/z/r1P3zx38a
The text was updated successfully, but these errors were encountered: