[PATCH] D98237: [clang-format] Option for empty lines after an access modifier.

Max Sagebaum via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 10 02:11:33 PST 2021


Max_S added inline comments.


================
Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:1284
       (!PreviousLine->InPPDirective || !RootToken.HasUnescapedNewline))
-    Newlines = std::min(1u, Newlines);
+    Newlines = Style.EmptyLinesAfterAccessModifier + 1u;
 
----------------
HazardyKnusperkeks wrote:
> I don't know, I'm just asking:
> Shouldn't this be `Newlines = std::min(Newlines, Style.EmptyLinesAfterAccessModifier + 1u);`?
This is also possible but then the logic would be how many lines should be kept at maximum after an access specifier.

The name would then be `Style.KeepMaximumLinesAfterAccessModifier`.

Currently the logic above:
```
  if (Newlines == 0 && !RootToken.IsFirst)
    Newlines = 1;
```
forces Newlines to be always 1 or bigger. Therefore the old logic would always add one new line and I decided to implement the setting in the same way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98237



More information about the cfe-commits mailing list