[clang-tools-extra] [clang-tidy] add new check readability-enum-initial-value (PR #86129)

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 21 10:53:54 PDT 2024


================
@@ -0,0 +1,27 @@
+// RUN: %check_clang_tidy %s readability-enum-initial-value %t
+
+enum class EError {
+  // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: inital value in enum EError has readability issue, explicit initialization of all of enumerators
+  EError_a = 1,
+  EError_b,
+  // CHECK-FIXES: EError_b = 2,
+  EError_c = 3,
+};
+
+enum class ENone {
+  ENone_a,
+  ENone_b,
+  eENone_c,
+};
+
+enum class EFirst {
+  EFirst_a = 1,
+  EFirst_b,
+  EFirst_c,
+};
+
+enum class EAll {
+  EAll_a = 1,
+  EAll_b = 2,
+  EAll_c = 3,
+};
----------------
PiotrZSL wrote:

add some tests with macros, like where name of enum constant is behind macro.

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


More information about the cfe-commits mailing list