diff options
author | Daniel Jasper <djasper@google.com> | 2013-01-22 11:46:26 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-01-22 11:46:26 +0000 |
commit | ffee17126e10a0e2febfcfbf61d8e0d6e2fcf4c0 (patch) | |
tree | 93e1a384b188e2d3853143d1df86e8801376cf03 /lib/Format/Format.cpp | |
parent | 9ec55f24b8f848bb37a9971100cf2fca379d5572 (diff) |
Fix "*" formatting when creating arrays of pointers.
Before: A = new int * [10]();
After: A = new int *[10]();
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173150 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/Format.cpp')
-rw-r--r-- | lib/Format/Format.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 05c96bd38d..e9ff3c9b12 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -958,6 +958,13 @@ public: while (CurrentToken != NULL) { if (CurrentToken->is(tok::r_square)) { + if (!CurrentToken->Children.empty() && + CurrentToken->Children[0].is(tok::l_paren)) { + // An ObjC method call can't be followed by an open parenthesis. + // FIXME: Do we incorrectly label ":" with this? + StartsObjCMethodExpr = false; + Left->Type = TT_Unknown; + } if (StartsObjCMethodExpr) objCSelector.markEnd(*CurrentToken); Left->MatchingParen = CurrentToken; @@ -1325,6 +1332,9 @@ private: if (NextToken == NULL) return TT_Unknown; + if (NextToken->is(tok::l_square) && NextToken->Type != TT_ObjCMethodExpr) + return TT_PointerOrReference; + if (PrevToken->is(tok::l_paren) || PrevToken->is(tok::l_square) || PrevToken->is(tok::l_brace) || PrevToken->is(tok::comma) || PrevToken->is(tok::kw_return) || PrevToken->is(tok::colon) || |