]> granicus.if.org Git - clang/commitdiff
Extend bracket insertion to message sends to "super", e.g.,
authorDouglas Gregor <dgregor@apple.com>
Wed, 15 Sep 2010 15:09:43 +0000 (15:09 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 15 Sep 2010 15:09:43 +0000 (15:09 +0000)
  super method:arg]

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

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

lib/Parse/ParseExpr.cpp
test/FixIt/fixit-objc-message.m

index e466af2d614757eeb98036e2835aa5aefb258534..0f9154827e944f50a9da9716e3bfa844d0025f5e 100644 (file)
@@ -663,6 +663,18 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
       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;
index f19b489f997ba03ed041d06eefdc0c363a49b7d7..72728d20adc74d97ce413a7058937c6310cc552d 100644 (file)
@@ -18,4 +18,18 @@ void f(A *a, int i, int j) {
   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)]];
 }
+
+@interface B : A
+- (int)method1:(int)x second:(float)y;
+@end
+
+@implementation B
+- (int)method1:(int)x second:(float)y {
+  super method1:x second:y];
+  return super getBlah];
+}
+@end