[cfe-commits] r172302 - in /cfe/trunk: lib/Format/Format.cpp unittests/Format/FormatTest.cpp

Nico Weber nicolasweber at gmx.de
Fri Jan 11 21:47:16 PST 2013


Author: nico
Date: Fri Jan 11 23:47:16 2013
New Revision: 172302

URL: http://llvm.org/viewvc/llvm-project?rev=172302&view=rev
Log:
Formatter: * and & are binary operators after ) and ].

Modified:
    cfe/trunk/lib/Format/Format.cpp
    cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=172302&r1=172301&r2=172302&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Fri Jan 11 23:47:16 2013
@@ -969,7 +969,8 @@
         Tok.Parent->Type == TT_CastRParen)
       return TT_UnaryOperator;
 
-    if (PrevToken.Tok.isLiteral() || NextToken.Tok.isLiteral() ||
+    if (PrevToken.Tok.isLiteral() || PrevToken.Tok.is(tok::r_paren) ||
+        PrevToken.Tok.is(tok::r_square) || NextToken.Tok.isLiteral() ||
         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) ||

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=172302&r1=172301&r2=172302&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Jan 11 23:47:16 2013
@@ -1014,6 +1014,8 @@
   verifyFormat("a * -b;");
   verifyFormat("a * ++b;");
   verifyFormat("a * --b;");
+  verifyFormat("a[4] * b;");
+  verifyFormat("f() * b;");
   verifyFormat("int *pa = (int *)&a;");
 
   verifyFormat("InvalidRegions[*R] = 0;");





More information about the cfe-commits mailing list