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 | |
| 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')
| -rw-r--r-- | clang/lib/Format/Format.cpp | 2 | ||||
| -rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 14 |
2 files changed, 10 insertions, 6 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index c0ed6c5be19..39efeab52c6 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -1033,6 +1033,8 @@ private: if (Left.is(tok::at) && Right.FormatTok.Tok.getObjCKeywordID() != tok::objc_not_keyword) return false; + if (Left.is(tok::l_brace) && Right.is(tok::r_brace)) + return false; return true; } 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; } |

