[PATCH] D132131: [clang-format] Adds a formatter for aligning trailing comments over empty lines

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 31 09:40:02 PDT 2022


HazardyKnusperkeks added inline comments.


================
Comment at: clang/include/clang/Format/Format.h:141
 
-  /// Alignment options.
-  ///
-  /// They can also be read as a whole for compatibility. The choices are:
+  /// Alignment styles of ``AlignConsecutiveStyle`` are:
   /// - None
----------------
That I wouldn't change.


================
Comment at: clang/include/clang/Format/Format.h:154
   /// \code
   ///   AlignConsecutiveMacros: AcrossEmptyLines
   ///
----------------
The change/addition has to be here, since here it directly states `AlignConsecutiveMacros`.


================
Comment at: clang/unittests/Format/FormatTestComments.cpp:2863
+  FormatStyle Style = getLLVMStyle();
+  Style.AlignConsecutiveTrailingComments.AcrossEmptyLines = true;
+  verifyFormat("#include \"a.h\"  // simple\n"
----------------
yusuke-kadowaki wrote:
> HazardyKnusperkeks wrote:
> > Interesting would be a comment which is split, do we continue to align, or not?
> Could you give me a specific example?
Something like
```
int foo = 2323234; // Comment
int bar = 52323;   // This is a very long comment, ...
                   // which is wrapped around.

int x = 2; // Is this still aligned?
```
You may need to make the comment longer or reduce the column limit, as often used for testing the wrapping behavior.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132131/new/

https://reviews.llvm.org/D132131



More information about the cfe-commits mailing list