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

Nico Weber nicolasweber at gmx.de
Sat Jan 12 15:48:49 PST 2013


Author: nico
Date: Sat Jan 12 17:48:49 2013
New Revision: 172337

URL: http://llvm.org/viewvc/llvm-project?rev=172337&view=rev
Log:
Formatter: Don't insert a space before unary operators after selector names.

Before:
  [color getRed: &r green: &g blue: &b alpha: &a];

Now:
  [color getRed:&r green:&g blue:&b alpha:&a];


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=172337&r1=172336&r2=172337&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Sat Jan 12 17:48:49 2013
@@ -1165,8 +1165,9 @@
       return false;
     if (Tok.Type == TT_UnaryOperator)
       return Tok.Parent->isNot(tok::l_paren) &&
-             Tok.Parent->isNot(tok::l_square) &&
-             Tok.Parent->isNot(tok::at);
+             Tok.Parent->isNot(tok::l_square) && Tok.Parent->isNot(tok::at) &&
+             (Tok.Parent->isNot(tok::colon) ||
+              Tok.Parent->Type != TT_ObjCMethodExpr);
     if (Tok.Parent->is(tok::greater) && Tok.is(tok::greater)) {
       return Tok.Type == TT_TemplateCloser && Tok.Parent->Type ==
              TT_TemplateCloser && Style.SplitTemplateClosingGreater;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=172337&r1=172336&r2=172337&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Sat Jan 12 17:48:49 2013
@@ -1533,6 +1533,7 @@
   verifyFormat("[self stuffWithInt:a ? (e ? f : g) : c];");
   verifyFormat("[cond ? obj1 : obj2 methodWithParam:param]");
   verifyFormat("[button setAction:@selector(zoomOut:)];");
+  verifyFormat("[color getRed:&r green:&g blue:&b alpha:&a];");
   
   verifyFormat("arr[[self indexForFoo:a]];");
   verifyFormat("throw [self errorFor:a];");





More information about the cfe-commits mailing list