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

Yusuke Kadowaki via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 31 06:21:58 PDT 2022


yusuke-kadowaki added inline comments.


================
Comment at: clang/docs/ClangFormatStyleOptions.rst:785
+  - Consecutive
+  - AcrossEmptyLines
+  - AcrossComments
----------------
HazardyKnusperkeks wrote:
> yusuke-kadowaki wrote:
> > MyDeveloperDay wrote:
> > > may be AcrossEmptyLines should be a number (to mean the number of empty lines)
> > We need to introduce a new struct to do that since AlignConsecutiveStyle is shared with some options and not possible to be changed. Plus I think more than two empty lines are formatted to one empty line anyway.
> There `MaxEmptyLinesToKeep` which would allow to set it higher.
> 
> If we want to change the `bool` to an `unsigned`, then that should be a different change.
Oh I didn't know `MaxEmptyLinesToKeep`. Thank you for sharing.
I can try to change it that way when we done with this patch. Test cases would be complicated tho.


================
Comment at: clang/unittests/Format/FormatTestComments.cpp:2863
+  FormatStyle Style = getLLVMStyle();
+  Style.AlignConsecutiveTrailingComments.AcrossEmptyLines = true;
+  verifyFormat("#include \"a.h\"  // simple\n"
----------------
HazardyKnusperkeks wrote:
> Interesting would be a comment which is split, do we continue to align, or not?
Could you give me a specific example?


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