aboutsummaryrefslogtreecommitdiff
path: root/lib/Format/UnwrappedLineParser.cpp
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2013-01-10 13:24:24 +0000
committerManuel Klimek <klimek@google.com>2013-01-10 13:24:24 +0000
commit36fab8d70eee342d66e03c9b09c029f126196103 (patch)
tree9a24e011325a032e70cce92707687997af9c147f /lib/Format/UnwrappedLineParser.cpp
parent46ef852618b18bc79e403b37a12c9b692e76126b (diff)
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
Diffstat (limited to 'lib/Format/UnwrappedLineParser.cpp')
-rw-r--r--lib/Format/UnwrappedLineParser.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp
index 736178e1eb..e9c6211313 100644
--- a/lib/Format/UnwrappedLineParser.cpp
+++ b/lib/Format/UnwrappedLineParser.cpp
@@ -167,15 +167,17 @@ bool UnwrappedLineParser::parseBlock(unsigned AddLevels) {
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;
}