[clang-tools-extra] [clang-tidy] Add AllowReferencedInitialValues to `readability-enum-initial-value` (PR #189459)
Björn Svensson via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 6 03:05:19 PDT 2026
================
@@ -26,6 +26,32 @@ enum ESeqRef {
ESeqRef_alias = ESeqRef_a,
};
+// Error: sequential + multiple self-refs, should still warn and suggest
+// removing the sequential values but not the self-refs.
+enum ESeqMultiRef {
+ // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: sequential initial value in 'ESeqMultiRef' can be ignored
+ ESeqMultiRef_a = 1,
+ ESeqMultiRef_b = 2,
+ // CHECK-FIXES: ESeqMultiRef_b ,
+ ESeqMultiRef_c = 3,
+ // CHECK-FIXES: ESeqMultiRef_c ,
+ ESeqMultiRef_alias = ESeqMultiRef_a,
+ ESeqMultiRef_alias2 = ESeqMultiRef_b,
+};
+
+// Error: sequential + self-refs interleaved with the sequence, should still
+// warn and suggest removing the sequential values but not the self-refs.
+enum ESeqInterRef {
+ // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: sequential initial value in 'ESeqInterRef' can be ignored
+ ESeqInterRef_a = 1,
+ ESeqInterRef_alias = ESeqInterRef_a,
+ ESeqInterRef_b = 2,
+ // CHECK-FIXES: ESeqInterRef_b ,
+ ESeqInterRef_c = 3,
+ // CHECK-FIXES: ESeqInterRef_c ,
+ ESeqInterRef_alias2 = ESeqInterRef_b,
----------------
bjosv wrote:
Oh yes, well spotted. Added a correction for this and a testcase
https://github.com/llvm/llvm-project/pull/189459
More information about the cfe-commits
mailing list