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

Daniel Jasper djasper at google.com
Fri Jan 4 12:46:39 PST 2013


Author: djasper
Date: Fri Jan  4 14:46:38 2013
New Revision: 171522

URL: http://llvm.org/viewvc/llvm-project?rev=171522&view=rev
Log:
Correctly format dereference and address of in array parameters.

Before: InvalidRegions[ &R] = 0;
After:  InvalidRegions[&R] = 0;

This fixes llvm.org/PR14793

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=171522&r1=171521&r2=171522&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Fri Jan  4 14:46:38 2013
@@ -878,8 +878,9 @@
     const FormatToken &PrevToken = Line.Tokens[Index - 1];
     const FormatToken &NextToken = Line.Tokens[Index + 1];
 
-    if (PrevToken.Tok.is(tok::l_paren) || PrevToken.Tok.is(tok::comma) ||
-        PrevToken.Tok.is(tok::kw_return) || PrevToken.Tok.is(tok::colon) ||
+    if (PrevToken.Tok.is(tok::l_paren) || PrevToken.Tok.is(tok::l_square) ||
+        PrevToken.Tok.is(tok::comma) || PrevToken.Tok.is(tok::kw_return) ||
+        PrevToken.Tok.is(tok::colon) ||
         Annotations[Index - 1].Type == TokenAnnotation::TT_BinaryOperator)
       return TokenAnnotation::TT_UnaryOperator;
 

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=171522&r1=171521&r2=171522&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Jan  4 14:46:38 2013
@@ -768,6 +768,8 @@
   verifyFormat("a * ++b;");
   verifyFormat("a * --b;");
 
+  verifyFormat("InvalidRegions[*R] = 0;");
+
   // FIXME: Is this desired for LLVM? Fix if not.
   verifyFormat("A<int *> a;");
   verifyFormat("A<int **> a;");





More information about the cfe-commits mailing list