aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-01-29 09:42:11 +0000
committerDaniel Jasper <djasper@google.com>2013-01-29 09:42:11 +0000
commit8df364fc0b3d89fb4ea632c6824a121a8c7752a5 (patch)
tree984cb6f6c51be159c5cad7f8dd8162b1416da206
parent4cd81c5bf5957b2b10ddf253035f6e1596082108 (diff)
Remove empty lines before "}".
Those empty lines waste vertical whitespace and almost never increase readability. Before: void f() { DoSomething(); } After: void f() { DoSomething(); } git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173785 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Format/Format.cpp2
-rw-r--r--unittests/Format/FormatTest.cpp1
2 files changed, 3 insertions, 0 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index 8eebda0740..58e6648ca3 100644
--- a/lib/Format/Format.cpp
+++ b/lib/Format/Format.cpp
@@ -1990,6 +1990,8 @@ private:
Style.MaxEmptyLinesToKeep + 1);
if (Newlines == 0 && !Tok.IsFirst)
Newlines = 1;
+ if (Tok.Tok.is(tok::r_brace) && Newlines > 1)
+ Newlines = 1;
unsigned Indent = Level * 2;
bool IsAccessModifier = false;
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 63110bbfbe..ef242d7258 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -136,6 +136,7 @@ TEST_F(FormatTest, FormatsUnwrappedLinesAtFirstFormat) {
TEST_F(FormatTest, FormatsNestedBlockStatements) {
EXPECT_EQ("{\n {\n {}\n }\n}", format("{{{}}}"));
+ EXPECT_EQ("{\n {\n {}\n }\n}", format("{{{}}\n\n}"));
}
TEST_F(FormatTest, FormatsNestedCall) {