[clang-tools-extra] [clang-tidy] Fixed bugprone-non-zero-enum-to-bool-conversion (PR #131407)
Baranov Victor via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 19 05:24:41 PDT 2025
================
@@ -19,16 +19,22 @@ namespace clang::tidy::bugprone {
namespace {
-AST_MATCHER(EnumDecl, isCompleteAndHasNoZeroValue) {
+AST_MATCHER(EnumDecl, isCompleteNonEmptyAndHasNoZeroValue) {
const EnumDecl *Definition = Node.getDefinition();
return Definition && Node.isComplete() &&
+ Definition->enumerator_begin() != Definition->enumerator_end() &&
----------------
vbvictor wrote:
nit: maybe `Definition->enumerators().empty()` is a bit more readable.
it has `enumerator_begin != enumerator_end` under the hood
https://github.com/llvm/llvm-project/pull/131407
More information about the cfe-commits
mailing list