[llvm-branch-commits] [clang-tools-extra] [clang-tidy][docs] Rewrite readability check docs to Markdown [1/5] (PR #221447)
Baranov Victor via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Sep 7 01:21:11 PDT 2026
================
@@ -12,100 +12,97 @@ enumerators that obtain their integer representation implicitly.
The following three cases are accepted:
-#. **No** enumerators are explicit initialized.
-#. Exactly **the first** enumerator is explicit initialized.
-#. **All** enumerators are explicit initialized.
-
-.. code-block:: c++
-
- enum A { // (1) Valid, none of enumerators are initialized.
- a0,
- a1,
- a2,
- };
-
- enum B { // (2) Valid, the first enumerator is initialized.
- b0 = 0,
- b1,
- b2,
- };
-
- enum C { // (3) Valid, all of enumerators are initialized.
- c0 = 0,
- c1 = 1,
- c2 = 2,
- };
-
- enum D { // warning: initial values in enum 'D' are not consistent,
- // consider explicit initialization of all, none or only
- // the first enumerator
- d0 = 0,
- d1, // note: uninitialized enumerator 'd1' defined here
- d2 = 2,
- };
-
- enum E { // warning: initial values in enum 'E' are not consistent,
- // consider explicit initialization of all, none or only
- // the first enumerator
- e0 = 0,
- e1, // note: uninitialized enumerator 'e1' defined here
- e2 = 2,
- e3, // note: uninitialized enumerator 'e3' defined here
- // Dangerous, as the numeric values of e3 and e5 are both 3,
- // and this is not explicitly visible in the code!
- e4 = 2,
- e5, // note: uninitialized enumerator 'e5' defined here
- };
-
-This check corresponds to the CERT C Coding Standard recommendation `INT09-C. Ensure enumeration constants map to unique values
-<https://cmu-sei.github.io/secure-coding-standards/sei-cert-c-coding-standard/recommendations/integers-int/int09-c/>`_.
+1. **No** enumerators are explicit initialized.
+2. Exactly **the first** enumerator is explicit initialized.
+3. **All** enumerators are explicit initialized.
+
+```c++
+enum A { // (1) Valid, none of enumerators are initialized.
+ a0,
+ a1,
+ a2,
+};
+
+enum B { // (2) Valid, the first enumerator is initialized.
+ b0 = 0,
+ b1,
+ b2,
+};
+
+enum C { // (3) Valid, all of enumerators are initialized.
+ c0 = 0,
+ c1 = 1,
+ c2 = 2,
+};
+
+enum D { // warning: initial values in enum 'D' are not consistent,
+ // consider explicit initialization of all, none or only
+ // the first enumerator
+ d0 = 0,
+ d1, // note: uninitialized enumerator 'd1' defined here
+ d2 = 2,
+};
+
+enum E { // warning: initial values in enum 'E' are not consistent,
+ // consider explicit initialization of all, none or only
+ // the first enumerator
+ e0 = 0,
+ e1, // note: uninitialized enumerator 'e1' defined here
+ e2 = 2,
+ e3, // note: uninitialized enumerator 'e3' defined here
+ // Dangerous, as the numeric values of e3 and e5 are both 3,
+ // and this is not explicitly visible in the code!
+ e4 = 2,
+ e5, // note: uninitialized enumerator 'e5' defined here
+};
+```
+
+This check corresponds to the CERT C Coding Standard recommendation [INT09-C. Ensure enumeration constants map to unique values](https://cmu-sei.github.io/secure-coding-standards/sei-cert-c-coding-standard/recommendations/integers-int/int09-c/).
`cert-int09-c` redirects here as an alias of this check.
-Options
--------
-
-.. option:: AllowExplicitZeroFirstInitialValue
-
- If set to `false`, the first enumerator must not be explicitly initialized to
- a literal ``0``.
- Default is `true`.
-
- .. code-block:: c++
-
- enum F {
- f0 = 0, // Not allowed if AllowExplicitZeroFirstInitialValue is false.
- f1,
- f2,
- };
-
-
-.. option:: AllowExplicitSequentialInitialValues
-
- If set to `false`, explicit initialization to sequential values are not
- allowed.
- Default is `true`.
-
- .. code-block:: c++
-
- enum G {
- g0 = 1, // Not allowed if AllowExplicitSequentialInitialValues is false.
- g1 = 2,
- g2 = 3,
- };
-
-.. option:: AllowReferencedInitialValues
-
- If set to `true`, enumerators initialized by referencing another enumerator
- in the same enum are allowed, and the remaining enumerators are checked for
- consistency. This implements the `INT09-C-EX1` exception from the CERT C
- Coding Standard.
- Default is `false`.
-
- .. code-block:: c++
-
- enum H {
- h0,
- h1,
- h2 = h1, // Allowed if AllowReferencedInitialValues is true.
- };
+## Options
+
+````{option} AllowExplicitZeroFirstInitialValue
+When `false`, the first enumerator must not be explicitly initialized to
+a literal `0`.
+Default is `true`.
+
+```c++
+enum F {
+ f0 = 0, // Not allowed if AllowExplicitZeroFirstInitialValue is false.
+ f1,
+ f2,
+};
+```
+````
+
+````{option} AllowExplicitSequentialInitialValues
----------------
vbvictor wrote:
We need 4 ticks because of ```c++`?
https://github.com/llvm/llvm-project/pull/221447
More information about the llvm-branch-commits
mailing list