]> granicus.if.org Git - clang/commitdiff
Remove empty lines before "}".
authorDaniel Jasper <djasper@google.com>
Tue, 29 Jan 2013 09:42:11 +0000 (09:42 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 29 Jan 2013 09:42:11 +0000 (09:42 +0000)
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

lib/Format/Format.cpp
unittests/Format/FormatTest.cpp

index 8eebda0740b97b57b839058ce587a25cb67fbed7..58e6648ca30c7d467a4332b22302b99272a58fef 100644 (file)
@@ -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;
index 63110bbfbe0099dbe007a8b0c2a0454981c5a403..ef242d7258a9d2c902b22bfd33c7e55d1d12a9bf 100644 (file)
@@ -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) {