[PATCH] D93846: [clang-format] PR16518 Add flag to suppress empty line insertion before access modifier

Albertas Vyšniauskas via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 4 09:31:15 PST 2021


thezbyg marked an inline comment as done.
thezbyg added inline comments.


================
Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:1221
+    if (Style.EmptyLineBeforeAccessModifier &&
+        PreviousLine->Last->isOneOf(tok::semi, tok::r_brace) &&
+        RootToken.NewlinesBefore == 1)
----------------
MyDeveloperDay wrote:
> maybe I don't understand the logic but why is this `r_brace` and shouldn't we be looking at the "Last Non Comment" token?
I think that the logic is to only add empty line when access modifier is after member function body (`r_brace` indicates this) or declaration of field/function. If this check is changed to look at "last non comment" token, then empty line will be inserted in code like this:
```
struct Foo {
  int i;
  //comment
private:
  int j;
}
```


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

https://reviews.llvm.org/D93846



More information about the cfe-commits mailing list