[clang-tools-extra] Add check 'modernize-use-enum-class' (PR #138282)

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Fri May 9 09:44:44 PDT 2025


================
@@ -0,0 +1,31 @@
+.. title:: clang-tidy - cppcoreguidelines-use-enum-class
+
+cppcoreguidelines-use-enum-class
+=============================
+
+Finds plain non-class ``enum`` definitions that could use ``enum class``.
+
+This check implements `Enum.3
+<https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Renum-class>`_
+from the C++ Core Guidelines."
+
+Example:
+
+.. code-block:: c++
+
+  enum E {};        // use "enum class E {};" instead
+  enum class E {};  // OK
+
+  struct S {
+      enum E {};    // use "enum class E {};" instead
+                    // OK with option IgnoreUnscopedEnumsInClasses
+  };
+
+  namespace N {
+      enum E {};    // use "enum class E {};" instead
+  }
+
+
----------------
vbvictor wrote:

Please add this two lines before declaring options.
```rst
Options
-------
```
See any other check with options for reference.

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


More information about the cfe-commits mailing list