clang-format: Don't remove empty lines at the start of namespaces.

llvm-svn: 204462
This commit is contained in:
Daniel Jasper 2014-03-21 13:03:33 +00:00
parent 3df5d87da4
commit 01b35482e5
2 changed files with 12 additions and 1 deletions

View File

@ -889,7 +889,8 @@ private:
Newlines = 1;
// Remove empty lines after "{".
if (PreviousLine && PreviousLine->Last->is(tok::l_brace))
if (PreviousLine && PreviousLine->Last->is(tok::l_brace) &&
PreviousLine->First->isNot(tok::kw_namespace))
Newlines = 1;
// Insert extra new line before access specifiers.

View File

@ -174,6 +174,16 @@ TEST_F(FormatTest, RemovesEmptyLines) {
"\n"
"};"));
// Don't remove empty lines at the start of namespaces.
EXPECT_EQ("namespace N {\n"
"\n"
"int i;\n"
"}",
format("namespace N {\n"
"\n"
"int i;\n"
"}"));
// Remove empty lines at the beginning and end of blocks.
EXPECT_EQ("void f() {\n"
" if (a) {\n"