]> granicus.if.org Git - clang/commitdiff
Formatter: Don't insert a space before unary operators after selector names.
authorNico Weber <nicolasweber@gmx.de>
Sat, 12 Jan 2013 23:48:49 +0000 (23:48 +0000)
committerNico Weber <nicolasweber@gmx.de>
Sat, 12 Jan 2013 23:48:49 +0000 (23:48 +0000)
Before:
  [color getRed: &r green: &g blue: &b alpha: &a];

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172337 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 94119325410e4af1a209d63ec75fed06ba4e358a..29debe58b6b1e44d66243309fd51ed876fb0ca45 100644 (file)
@@ -1165,8 +1165,9 @@ private:
       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;
index 8bb217e4833e274c52896640b499d92e4dcc91a5..5ace0f82f91996325e65248da846d8e8732a5180 100644 (file)
@@ -1533,6 +1533,7 @@ TEST_F(FormatTest, FormatObjCMethodExpr) {
   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];");