[clang] [clang-format] Fix bad comment indentation before ifdef after braceless if (PR #94776)

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 8 12:13:31 PDT 2024


================
@@ -4811,8 +4813,11 @@ void UnwrappedLineParser::readToken(int LevelDifference) {
            (!Style.isVerilog() ||
             Keywords.isVerilogPPDirective(*Tokens->peekNextToken())) &&
            FirstNonCommentOnLine) {
-      distributeComments(Comments, FormatTok);
-      Comments.clear();
+
+      if (!UnbracedBodyDepth) {
+        distributeComments(Comments, FormatTok);
+        Comments.clear();
+      }
----------------
owenca wrote:

```suggestion
      if (UnbracedBodyDepth == 0) {
        distributeComments(Comments, FormatTok);
        Comments.clear();
      }

```

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


More information about the cfe-commits mailing list