[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
Fri Jan 1 01:41:47 PST 2021
thezbyg added a comment.
When access modifier is in the same line with previous tokens, **UnwrappedLineFormatter::formatFirstToken** is called with **RootToken.NewlinesBefore** == 0, but empty line is only inserted if **RootToken.NewlinesBefore** == 1. The following change fixes this and passes all tests except the ones with comment:
if (PreviousLine && RootToken.isAccessSpecifier()) {
if (Style.EmptyLineBeforeAccessModifier &&
PreviousLine->Last->isOneOf(tok::semi, tok::r_brace) &&
- RootToken.NewlinesBefore == 1)
- ++Newlines;
+ RootToken.NewlinesBefore <= 1)
+ Newlines = 2;
else if (!Style.EmptyLineBeforeAccessModifier &&
RootToken.NewlinesBefore > 1)
Newlines = 1;
}
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93846/new/
https://reviews.llvm.org/D93846
More information about the cfe-commits
mailing list