]> granicus.if.org Git - clang/commitdiff
Formatter: * and & are binary operators before ( and [.
authorNico Weber <nicolasweber@gmx.de>
Sat, 12 Jan 2013 05:50:48 +0000 (05:50 +0000)
committerNico Weber <nicolasweber@gmx.de>
Sat, 12 Jan 2013 05:50:48 +0000 (05:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172303 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/Format.cpp
unittests/Format/FormatTest.cpp

index e4dc291312623b3aea7cf020c5dd8307b75d1716..aa534b9ef3fafd694e0428e2e5c510c40eebef38 100644 (file)
@@ -974,6 +974,7 @@ private:
         NextToken.Tok.is(tok::plus) || NextToken.Tok.is(tok::minus) ||
         NextToken.Tok.is(tok::plusplus) || NextToken.Tok.is(tok::minusminus) ||
         NextToken.Tok.is(tok::tilde) || NextToken.Tok.is(tok::exclaim) ||
+        NextToken.Tok.is(tok::l_paren) || NextToken.Tok.is(tok::l_square) ||
         NextToken.Tok.is(tok::kw_alignof) || NextToken.Tok.is(tok::kw_sizeof))
       return TT_BinaryOperator;
 
index e5dbd630202b2a12bdb68e5247e3f602877d5f87..4b3297db3df6f9e248bbe8983fb6b6940604bba8 100644 (file)
@@ -1016,6 +1016,9 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
   verifyFormat("a * --b;");
   verifyFormat("a[4] * b;");
   verifyFormat("f() * b;");
+  verifyFormat("a * [self dostuff];");
+  verifyFormat("a * (a + b);");
+  verifyFormat("(a *)(a + b);");
   verifyFormat("int *pa = (int *)&a;");
 
   verifyFormat("InvalidRegions[*R] = 0;");