[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
Fri Aug 19 12:29:26 PDT 2022


HazardyKnusperkeks added inline comments.


================
Comment at: clang/include/clang/Format/Format.h:379
   /// \version 3.7
   bool AlignTrailingComments;
 
----------------
Maybe you can port this to `AlignConsecutiveStyle`? `AcrossComments` would not affect anything in this context.


================
Comment at: clang/include/clang/Format/Format.h:381
 
+  bool AlignTrailingCommentsIgnoreEmptyLine;
+
----------------
Documentation is missing.


================
Comment at: clang/lib/Format/Format.cpp:1453
     GoogleStyle.AlignTrailingComments = false;
+    GoogleStyle.AlignTrailingCommentsIgnoreEmptyLine = false;
     GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
----------------
Not needed since it inherits everything from `LLVMStyle`.
Same for the other styles.


================
Comment at: clang/lib/Format/WhitespaceManager.cpp:930
   unsigned Newlines = 0;
+  unsigned int NewLineThr = Style.AlignTrailingCommentsIgnoreEmptyLine ? 2 : 1;
   for (unsigned i = 0, e = Changes.size(); i != e; ++i) {
----------------
Just make it clear for everyone, so one would not need to guess, when trying to understand the code.


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