]> granicus.if.org Git - clang/commitdiff
Formatter/ObjC: Correctly format casts in objc message send expressions.
authorNico Weber <nicolasweber@gmx.de>
Tue, 25 Jun 2013 00:55:57 +0000 (00:55 +0000)
committerNico Weber <nicolasweber@gmx.de>
Tue, 25 Jun 2013 00:55:57 +0000 (00:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184804 91177308-0d34-0410-b5e6-96231b3b80d8

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

index c6b491914b3c0d7fe69e0ec2d972f5a74a0f1bea..c5315e72600cbbb15e5ca874ff50d639a485eb62 100644 (file)
@@ -637,9 +637,8 @@ private:
         // there is also an identifier before the ().
         if (LeftOfParens && (LeftOfParens->Tok.getIdentifierInfo() == NULL ||
                              LeftOfParens->is(tok::kw_return)) &&
-            LeftOfParens->Type != TT_TemplateCloser &&
-            LeftOfParens->Type != TT_ObjCMethodExpr && Current.Next &&
-            (Current.Next->is(tok::identifier)))
+            LeftOfParens->Type != TT_TemplateCloser && Current.Next &&
+            Current.Next->is(tok::identifier))
           IsCast = true;
         if (IsCast && !ParensAreEmpty)
           Current.Type = TT_CastRParen;
index 839d9ec0be38be6aa5f1f30378e34d85fa7afef2..6b1d2d3f400c75ec95ac440ed11393768e3e757f 100644 (file)
@@ -4309,6 +4309,10 @@ TEST_F(FormatTest, FormatObjCMethodExpr) {
   verifyFormat("throw [self errorFor:a];");
   verifyFormat("@throw [self errorFor:a];");
 
+  verifyFormat("[(id)foo bar:(id)baz quux:(id)snorf];");
+  verifyFormat("[(id)foo bar:(id) ? baz : quux];");
+  verifyFormat("4 > 4 ? (id)a : (id)baz;");
+
   // This tests that the formatter doesn't break after "backing" but before ":",
   // which would be at 80 columns.
   verifyFormat(