diff options
author | Manuel Klimek <klimek@google.com> | 2013-01-10 13:24:24 +0000 |
---|---|---|
committer | Manuel Klimek <klimek@google.com> | 2013-01-10 13:24:24 +0000 |
commit | e7d10a1f5058fab3b0cca5453dfb4838922edd37 (patch) | |
tree | 6278cff69b1f77472f1b135163918deb6770395c /clang/lib/Format/UnwrappedLineParser.cpp | |
parent | 494394d817b89050619c50bc58b282813e7a63bc (diff) | |
download | bcm5719-llvm-e7d10a1f5058fab3b0cca5453dfb4838922edd37.tar.gz bcm5719-llvm-e7d10a1f5058fab3b0cca5453dfb4838922edd37.zip |
Do not add newline in empty blocks.
void f() {}
now gets formatted in one line.
llvm-svn: 172067
Diffstat (limited to 'clang/lib/Format/UnwrappedLineParser.cpp')
-rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 736178e1ebe..e9c6211313b 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/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; } |