r173785 - Remove empty lines before "}".
Daniel Jasper
djasper at google.com
Tue Jan 29 01:42:12 PST 2013
Author: djasper
Date: Tue Jan 29 03:42:11 2013
New Revision: 173785
URL: http://llvm.org/viewvc/llvm-project?rev=173785&view=rev
Log:
Remove empty lines before "}".
Those empty lines waste vertical whitespace and almost never
increase readability.
Before:
void f() {
DoSomething();
}
After:
void f() {
DoSomething();
}
Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=173785&r1=173784&r2=173785&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Tue Jan 29 03:42:11 2013
@@ -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;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=173785&r1=173784&r2=173785&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Jan 29 03:42:11 2013
@@ -136,6 +136,7 @@ TEST_F(FormatTest, FormatsUnwrappedLines
TEST_F(FormatTest, FormatsNestedBlockStatements) {
EXPECT_EQ("{\n {\n {}\n }\n}", format("{{{}}}"));
+ EXPECT_EQ("{\n {\n {}\n }\n}", format("{{{}}\n\n}"));
}
TEST_F(FormatTest, FormatsNestedCall) {
More information about the cfe-commits
mailing list