[clang-tools-extra] [clang-tidy] Add AllowExplicitReferencedInitialValues to `readability-enum-initial-value` (PR #189459)

Yanzuo Liu via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 11 22:34:02 PDT 2026


=?utf-8?q?Björn?= Svensson <bjorn.a.svensson at est.tech>,
=?utf-8?q?Björn?= Svensson <bjorn.a.svensson at est.tech>,
=?utf-8?q?Björn?= Svensson <bjorn.a.svensson at est.tech>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/189459 at github.com>


================
@@ -37,10 +59,13 @@ static bool isOnlyFirstEnumeratorInitialized(const EnumDecl &Node) {
   return !IsFirst;
 }
 
-static bool areAllEnumeratorsInitialized(const EnumDecl &Node) {
-  return llvm::all_of(Node.enumerators(), [](const EnumConstantDecl *ECD) {
-    return ECD->getInitExpr() != nullptr;
-  });
+static bool areAllEnumeratorsInitialized(const EnumDecl &Node,
+                                         bool AllowSelfRefs) {
+  return llvm::all_of(Node.enumerators(),
+                      [AllowSelfRefs](const EnumConstantDecl *ECD) {
+                        return isAllowedSelfReference(ECD, AllowSelfRefs) ||
----------------
zwuis wrote:

This condition is redundant.

https://github.com/llvm/llvm-project/pull/189459


More information about the cfe-commits mailing list