diff options
| author | Daniel Jasper <djasper@google.com> | 2014-05-22 12:46:38 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2014-05-22 12:46:38 +0000 |
| commit | 91b032ab5528ca64333497b0dd666a0dc1bf9b32 (patch) | |
| tree | 9c667c068199d491afd20f5b69dc1a44c844447d /clang/lib | |
| parent | 2dce43c26fa1d3894c482a83899a2781b0e1443c (diff) | |
| download | bcm5719-llvm-91b032ab5528ca64333497b0dd666a0dc1bf9b32.tar.gz bcm5719-llvm-91b032ab5528ca64333497b0dd666a0dc1bf9b32.zip | |
clang-format: Fix braced list detection.
Before:
static_assert(std::is_integral<int> {} + 0, "");
int a = std::is_integral<int> {}
+ 0;
After:
static_assert(std::is_integral<int>{} + 0, "");
int a = std::is_integral<int>{} + 0;
llvm-svn: 209431
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index e0106d94cf8..d0750af1b0f 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -338,6 +338,11 @@ void UnwrappedLineParser::calculateBraceTypes() { if (Style.Language == FormatStyle::LK_Proto) { ProbablyBracedList = NextTok->isOneOf(tok::comma, tok::r_square); } else { + // Using OriginalColumn to distinguish between ObjC methods and + // binary operators is a bit hacky. + bool NextIsObjCMethod = NextTok->isOneOf(tok::plus, tok::minus) && + NextTok->OriginalColumn == 0; + // If there is a comma, semicolon or right paren after the closing // brace, we assume this is a braced initializer list. Note that // regardless how we mark inner braces here, we will overwrite the @@ -350,8 +355,7 @@ void UnwrappedLineParser::calculateBraceTypes() { NextTok->isOneOf(tok::comma, tok::semi, tok::period, tok::colon, tok::r_paren, tok::r_square, tok::l_brace, tok::l_paren) || - (NextTok->isBinaryOperator() && - !NextTok->isOneOf(tok::plus, tok::minus)); + (NextTok->isBinaryOperator() && !NextIsObjCMethod); } if (ProbablyBracedList) { Tok->BlockKind = BK_BracedInit; |

