[cfe-commits] r125587 - in /cfe/trunk: lib/Parse/ParseExpr.cpp test/Index/complete-objc-message.m

Douglas Gregor dgregor at apple.com
Tue Feb 15 11:17:31 PST 2011


Author: dgregor
Date: Tue Feb 15 13:17:31 2011
New Revision: 125587

URL: http://llvm.org/viewvc/llvm-project?rev=125587&view=rev
Log:
When we encounter an Objective-C class name in an expression, followed
by the code completion token, treat this as a class message send where
the opening square bracket is missing. Fixes <rdar://problem/6970911>.

Modified:
    cfe/trunk/lib/Parse/ParseExpr.cpp
    cfe/trunk/test/Index/complete-objc-message.m

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=125587&r1=125586&r2=125587&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Tue Feb 15 13:17:31 2011
@@ -669,12 +669,17 @@
       break;
     }
     
-    // If we have an Objective-C class name followed by an identifier and
-    // either ':' or ']', this is an Objective-C class message send that's
-    // missing the opening '['. Recovery appropriately.
-    if (getLang().ObjC1 && Tok.is(tok::identifier) && !InMessageExpression) {
+    // If we have an Objective-C class name followed by an identifier
+    // and either ':' or ']', this is an Objective-C class message
+    // send that's missing the opening '['. Recovery
+    // appropriately. Also take this path if we're performing code
+    // completion after an Objective-C class name.
+    if (getLang().ObjC1 && 
+        ((Tok.is(tok::identifier) && !InMessageExpression) || 
+         Tok.is(tok::code_completion))) {
       const Token& Next = NextToken();
-      if (Next.is(tok::colon) || Next.is(tok::r_square))
+      if (Tok.is(tok::code_completion) || 
+          Next.is(tok::colon) || Next.is(tok::r_square))
         if (ParsedType Typ = Actions.getTypeName(II, ILoc, getCurScope()))
           if (Typ.get()->isObjCObjectOrInterfaceType()) {
             // Fake up a Declarator to use with ActOnTypeName.

Modified: cfe/trunk/test/Index/complete-objc-message.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-objc-message.m?rev=125587&r1=125586&r2=125587&view=diff
==============================================================================
--- cfe/trunk/test/Index/complete-objc-message.m (original)
+++ cfe/trunk/test/Index/complete-objc-message.m Tue Feb 15 13:17:31 2011
@@ -171,6 +171,10 @@
 }
 @end
 
+void test_missing_open_more() {
+  A *a = A class_method3];
+}
+
 // RUN: c-index-test -code-completion-at=%s:23:19 %s | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: {TypedText categoryClassMethod}
 // CHECK-CC1: {TypedText classMethod1:}{Placeholder (id)}{HorizontalSpace  }{TypedText withKeyword:}{Placeholder (int)}
@@ -294,3 +298,4 @@
 // RUN: c-index-test -code-completion-at=%s:141:23 %s | FileCheck -check-prefix=CHECK-CCD %s
 // RUN: c-index-test -code-completion-at=%s:141:30 %s | FileCheck -check-prefix=CHECK-CCE %s
 
+// RUN: c-index-test -code-completion-at=%s:175:12 %s | FileCheck -check-prefix=CHECK-CLASS-RESULT %s





More information about the cfe-commits mailing list