[cfe-commits] r113971 - in /cfe/trunk: lib/Parse/ParseExpr.cpp test/FixIt/fixit-objc-message.m

Douglas Gregor dgregor at apple.com
Wed Sep 15 08:09:43 PDT 2010


Author: dgregor
Date: Wed Sep 15 10:09:43 2010
New Revision: 113971

URL: http://llvm.org/viewvc/llvm-project?rev=113971&view=rev
Log:
Extend bracket insertion to message sends to "super", e.g.,

  super method:arg]

will now recover nicely and insert the '[' before 'super'.


Modified:
    cfe/trunk/lib/Parse/ParseExpr.cpp
    cfe/trunk/test/FixIt/fixit-objc-message.m

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=113971&r1=113970&r2=113971&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Sep 15 10:09:43 2010
@@ -663,6 +663,18 @@
       break;
     }
 
+    // In an Objective-C method, if we have "super" followed by an identifier,
+    // the token sequence is ill-fomed. However, if there's a ':' or ']' after
+    // that identifier, this is probably a message send with a missing open
+    // bracket. Treat it as such.
+    if (getLang().ObjC1 && &II == Ident_super && Tok.is(tok::identifier) &&
+        getCurScope()->isInObjcMethodScope() &&
+        (NextToken().is(tok::colon) || NextToken().is(tok::r_square))) {
+      Res = ParseObjCMessageExpressionBody(SourceLocation(), ILoc, ParsedType(), 
+                                           0);
+      break;
+    }
+    
     // Make sure to pass down the right value for isAddressOfOperand.
     if (isAddressOfOperand && isPostfixExpressionSuffixStart())
       isAddressOfOperand = false;

Modified: cfe/trunk/test/FixIt/fixit-objc-message.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit-objc-message.m?rev=113971&r1=113970&r2=113971&view=diff
==============================================================================
--- cfe/trunk/test/FixIt/fixit-objc-message.m (original)
+++ cfe/trunk/test/FixIt/fixit-objc-message.m Wed Sep 15 10:09:43 2010
@@ -18,4 +18,18 @@
   a method1:5+2 second:+(3.14159)];
   a method1:[a method1:3 second:j] second:i++]
   a getBlah];
+
+  int array[17];
+  (void)array[a method1:5+2 second:+(3.14159)]];
 }
+
+ at interface B : A
+- (int)method1:(int)x second:(float)y;
+ at end
+
+ at implementation B
+- (int)method1:(int)x second:(float)y {
+  super method1:x second:y];
+  return super getBlah];
+}
+ at end





More information about the cfe-commits mailing list