[llvm-branch-commits] [clang-tools-extra] [clang-tidy][docs] Rewrite readability check docs to Markdown [1/5] (PR #221447)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Sep 5 08:01:09 PDT 2026


================
@@ -1,90 +1,85 @@
-.. title:: clang-tidy - readability-else-after-return
+```{title} clang-tidy - readability-else-after-return
+```
 
-readability-else-after-return
-=============================
+# readability-else-after-return
 
-`LLVM Coding Standards <https://llvm.org/docs/CodingStandards.html>`_ advises to
+[LLVM Coding Standards](https://llvm.org/docs/CodingStandards.html) advises to
 reduce indentation where possible and where it makes understanding code easier.
 Early exit is one of the suggested enforcements of that. Please do not use
-``else`` or ``else if`` after something that interrupts control flow - like
-``return``, ``break``, ``continue``, ``throw``.
+`else` or `else if` after something that interrupts control flow - like
+`return`, `break`, `continue`, `throw`.
 
 The following piece of code illustrates how the check works.
 This piece of code:
 
-.. code-block:: c++
-
-    void foo(int Value) {
-      int Local = 0;
-      for (int i = 0; i < 42; i++) {
-        if (Value == 1) {
-          return;
-        } else {
-          Local++;
-        }
-
-        if (Value == 2)
-          continue;
-        else
-          Local++;
-
-        if (Value == 3) {
-          throw 42;
-        } else {
-          Local++;
-        }
-      }
+```c++
+void foo(int Value) {
+  int Local = 0;
+  for (int i = 0; i < 42; i++) {
+    if (Value == 1) {
+      return;
+    } else {
+      Local++;
     }
 
+    if (Value == 2)
+      continue;
+    else
+      Local++;
 
-Would be transformed into:
-
-.. code-block:: c++
-
-    void foo(int Value) {
-      int Local = 0;
-      for (int i = 0; i < 42; i++) {
-        if (Value == 1) {
-          return;
-        }
-        Local++;
-
-        if (Value == 2)
-          continue;
-        Local++;
-
-        if (Value == 3) {
-          throw 42;
-        }
-        Local++;
-      }
+    if (Value == 3) {
+      throw 42;
+    } else {
+      Local++;
     }
+  }
+}
+```
 
-Options
--------
-
-.. option:: WarnOnUnfixable
-
-   When `true`, emit a warning for cases where the check can't output a
-   Fix-It. These can occur with declarations inside the ``else`` branch that
-   would have an extended lifetime if the ``else`` branch was removed.
-   Default value is `true`.
-
-.. option:: WarnOnConditionVariables
+Would be transformed into:
 
-   When `true`, the check will attempt to refactor a variable defined inside
-   the condition of the ``if`` statement that is used in the ``else`` branch
-   defining them just before the ``if`` statement. This can only be done if
-   the ``if`` statement is the last statement in its parent's scope.
-   Default value is `true`.
+```c++
+void foo(int Value) {
+  int Local = 0;
+  for (int i = 0; i < 42; i++) {
+    if (Value == 1) {
+      return;
+    }
+    Local++;
 
+    if (Value == 2)
+      continue;
+    Local++;
 
-LLVM alias
-----------
+    if (Value == 3) {
+      throw 42;
+    }
+    Local++;
+  }
+}
+```
+
+## Options
+
+```{option} WarnOnUnfixable
+When `true`, emit a warning for cases where the check can't output a
+Fix-It. These can occur with declarations inside the `else` branch that
----------------
EugeneZelenko wrote:

```suggestion
fix-it. These can occur with declarations inside the `else` branch that
```

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


More information about the llvm-branch-commits mailing list