diff options
| author | Daniel Jasper <djasper@google.com> | 2015-05-13 12:54:30 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2015-05-13 12:54:30 +0000 |
| commit | 3a26a8db5d712337809fc1c7c1aad95c6d6d31e5 (patch) | |
| tree | f5ec2962c633acda38f10881ebc28e6640b6dee2 /clang | |
| parent | 0e919bca7f3748a304430e163fadcefd2dfcbb03 (diff) | |
| download | bcm5719-llvm-3a26a8db5d712337809fc1c7c1aad95c6d6d31e5.tar.gz bcm5719-llvm-3a26a8db5d712337809fc1c7c1aad95c6d6d31e5.zip | |
clang-format: Fix incorrect */& classification.
Before:
void f() { f(new a(), c *d); }
After:
void f() { f(new a(), c * d); }
llvm-svn: 237249
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 4 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 1 |
2 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 3e51417d2cd..130e2c3b2ac 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -234,6 +234,10 @@ private: MightBeObjCForRangeLoop = false; if (MightBeObjCForRangeLoop && CurrentToken->is(Keywords.kw_in)) CurrentToken->Type = TT_ObjCForIn; + // When we discover a 'new', we set CanBeExpression to 'false' in order to + // parse the type correctly. Reset that after a comma. + if (CurrentToken->is(tok::comma)) + Contexts.back().CanBeExpression = true; FormatToken *Tok = CurrentToken; if (!consumeToken()) diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index d6f0c08bf0a..c44708fbf6c 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -5486,6 +5486,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { verifyFormat("Constructor() : a(a), area(a, width * height) {}"); verifyGoogleFormat("MACRO Constructor(const int& i) : a(a), b(b) {}"); verifyFormat("void f() { f(a, c * d); }"); + verifyFormat("void f() { f(new a(), c * d); }"); verifyIndependentOfContext("InvalidRegions[*R] = 0;"); |

