I.e.:
#define A public:
// The new line before this line would be removed.
int a;
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@231636
91177308-0d34-0410-b5e6-
96231b3b80d8
++Newlines;
// Remove empty lines after access specifiers.
- if (PreviousLine && PreviousLine->First->isAccessSpecifier())
+ if (PreviousLine && PreviousLine->First->isAccessSpecifier() &&
+ (!PreviousLine->InPPDirective || !RootToken.HasUnescapedNewline))
Newlines = std::min(1u, Newlines);
Whitespaces->replaceWhitespace(RootToken, Newlines, IndentLevel, Indent,
"\n"
" void f();\n"
"};"));
+
+ // Even ensure proper spacing inside macros.
+ EXPECT_EQ("#define B \\\n"
+ " class A { \\\n"
+ " protected: \\\n"
+ " public: \\\n"
+ " void f(); \\\n"
+ " };",
+ format("#define B \\\n"
+ " class A { \\\n"
+ " protected: \\\n"
+ " \\\n"
+ " public: \\\n"
+ " \\\n"
+ " void f(); \\\n"
+ " };",
+ getGoogleStyle()));
+ // But don't remove empty lines after macros ending in access specifiers.
+ EXPECT_EQ("#define A private:\n"
+ "\n"
+ "int i;",
+ format("#define A private:\n"
+ "\n"
+ "int i;"));
}
TEST_F(FormatTest, FormatsClasses) {