They very rarely aid readability.
Formatting:
void f() {
if (a) {
f();
}
}
Now leads to:
void f() {
if (a) {
f();
}
}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204460
91177308-0d34-0410-b5e6-
96231b3b80d8
if (Newlines == 0 && !RootToken.IsFirst)
Newlines = 1;
+ // Remove empty lines after "{".
+ if (PreviousLine && PreviousLine->Last->is(tok::l_brace))
+ Newlines = 1;
+
// Insert extra new line before access specifiers.
if (PreviousLine && PreviousLine->Last->isOneOf(tok::semi, tok::r_brace) &&
RootToken.isAccessSpecifier() && RootToken.NewlinesBefore == 1)
"\n"
"};"));
+ // Remove empty lines at the beginning and end of blocks.
+ EXPECT_EQ("void f() {\n"
+ " if (a) {\n"
+ " f();\n"
+ " }\n"
+ "}",
+ format("void f() {\n"
+ "\n"
+ " if (a) {\n"
+ "\n"
+ " f();\n"
+ "\n"
+ " }\n"
+ "\n"
+ "}"));
+
// Don't remove empty lines in more complex control statements.
EXPECT_EQ("void f() {\n"
" if (a) {\n"