Do not add newline in empty blocks.
void f() {}
now gets formatted in one line.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172067 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp
index 736178e..e9c6211 100644
--- a/lib/Format/UnwrappedLineParser.cpp
+++ b/lib/Format/UnwrappedLineParser.cpp
@@ -167,15 +167,17 @@
assert(FormatTok.Tok.is(tok::l_brace) && "'{' expected");
nextToken();
- addUnwrappedLine();
+ if (!FormatTok.Tok.is(tok::r_brace)) {
+ addUnwrappedLine();
- Line->Level += AddLevels;
- parseLevel(/*HasOpeningBrace=*/true);
- Line->Level -= AddLevels;
+ Line->Level += AddLevels;
+ parseLevel(/*HasOpeningBrace=*/true);
+ Line->Level -= AddLevels;
- if (!FormatTok.Tok.is(tok::r_brace))
- return true;
+ if (!FormatTok.Tok.is(tok::r_brace))
+ return true;
+ }
nextToken(); // Munch the closing brace.
return false;
}