[clang] [Clang] Fix logical error in 'if else' condition that lead to an unreachable code (PR #95666)

via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 16 07:35:37 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff fa9745e8d39498a7090b108dd2717ca0466189e3 17e1c3561830866592fd3a55e7a296194b221a90 -- clang/lib/Format/TokenAnnotator.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 3bc7caaa95..4150c59ac5 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3369,12 +3369,12 @@ private:
       FormatToken *Next = Tok->getNextNonComment();
 
       if (Tok->is(tok::hash)) {
-          // Start of a macro expansion.
-          First = Tok;
-          Tok = Next;
-          if (Tok)
-            Tok = Tok->getNextNonComment();
-        }
+        // Start of a macro expansion.
+        First = Tok;
+        Tok = Next;
+        if (Tok)
+          Tok = Tok->getNextNonComment();
+      }
       } else if (Tok->is(tok::hashhash)) {
         // Concatenation. Skip.
         Tok = Next;

``````````

</details>


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


More information about the cfe-commits mailing list