r237249 - clang-format: Fix incorrect */& classification.
Daniel Jasper
djasper at google.com
Wed May 13 05:54:31 PDT 2015
Author: djasper
Date: Wed May 13 07:54:30 2015
New Revision: 237249
URL: http://llvm.org/viewvc/llvm-project?rev=237249&view=rev
Log:
clang-format: Fix incorrect */& classification.
Before:
void f() { f(new a(), c *d); }
After:
void f() { f(new a(), c * d); }
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=237249&r1=237248&r2=237249&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed May 13 07:54:30 2015
@@ -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())
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=237249&r1=237248&r2=237249&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed May 13 07:54:30 2015
@@ -5486,6 +5486,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStar
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;");
More information about the cfe-commits
mailing list