[clang] Add support for aligning BlockComments in declarations (PR #109497)

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 3 22:11:28 PST 2025


================
@@ -1022,7 +1028,10 @@ void WhitespaceManager::alignConsecutiveDeclarations() {
         if (C.Tok->is(TT_FunctionDeclarationName))
           return Style.AlignConsecutiveDeclarations.AlignFunctionDeclarations;
         if (C.Tok->isNot(TT_StartOfName))
-          return false;
+          if (!Style.AlignConsecutiveDeclarations.AlignBlockComments ||
+              !shouldAlignBlockComment(*C.Tok)) {
+            return false;
+          }
----------------
owenca wrote:

Please fold the nested `if` statements or run `ninja clang-format-check-format` and fix the formatting error below:
```
--- /Users/Owen/llvm-project/clang/lib/Format/WhitespaceManager.cpp	2025-01-03 21:22:11
+++ -	2025-01-03 22:07:03
@@ -1027,11 +1027,12 @@
         }
         if (C.Tok->is(TT_FunctionDeclarationName))
           return Style.AlignConsecutiveDeclarations.AlignFunctionDeclarations;
-        if (C.Tok->isNot(TT_StartOfName))
+        if (C.Tok->isNot(TT_StartOfName)) {
           if (!Style.AlignConsecutiveDeclarations.AlignBlockComments ||
               !shouldAlignBlockComment(*C.Tok)) {
             return false;
           }
+        }
         if (C.Tok->Previous &&
             C.Tok->Previous->is(TT_StatementAttributeLikeMacro))
           return false;

```

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


More information about the cfe-commits mailing list