[cfe-commits] r125628 - in /cfe/trunk: lib/Sema/SemaCodeComplete.cpp test/Index/complete-super.m

Douglas Gregor dgregor at apple.com
Tue Feb 15 16:51:18 PST 2011


Author: dgregor
Date: Tue Feb 15 18:51:18 2011
New Revision: 125628

URL: http://llvm.org/viewvc/llvm-project?rev=125628&view=rev
Log:
When trying to provide a code completion item for a call to "super" in
Objective-C, also look in the categories and class extensions of our
superclasses. Fixes <rdar://problem/8853540>.

Modified:
    cfe/trunk/lib/Sema/SemaCodeComplete.cpp
    cfe/trunk/test/Index/complete-super.m

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=125628&r1=125627&r2=125628&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Tue Feb 15 18:51:18 2011
@@ -4478,10 +4478,21 @@
   
   // Try to find a superclass method with the same selector.
   ObjCMethodDecl *SuperMethod = 0;
-  while ((Class = Class->getSuperClass()) && !SuperMethod)
+  while ((Class = Class->getSuperClass()) && !SuperMethod) {
+    // Check in the class
     SuperMethod = Class->getMethod(CurMethod->getSelector(), 
                                    CurMethod->isInstanceMethod());
 
+    // Check in categories or class extensions.
+    if (!SuperMethod) {
+      for (ObjCCategoryDecl *Category = Class->getCategoryList(); Category;
+           Category = Category->getNextClassCategory())
+        if ((SuperMethod = Category->getMethod(CurMethod->getSelector(), 
+                                               CurMethod->isInstanceMethod())))
+          break;
+    }
+  }
+
   if (!SuperMethod)
     return 0;
   

Modified: cfe/trunk/test/Index/complete-super.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-super.m?rev=125628&r1=125627&r2=125628&view=diff
==============================================================================
--- cfe/trunk/test/Index/complete-super.m (original)
+++ cfe/trunk/test/Index/complete-super.m Tue Feb 15 18:51:18 2011
@@ -26,6 +26,19 @@
 }
 @end
 
+ at interface A (Cat)
+- (void)multiply:(int)x by:(int)y;
+ at end
+
+ at interface C : A
+ at end
+
+ at implementation C
+- (void)multiply:(int)a by:(int)b {
+  [super multiply:a by:b];
+}
+ at end
+
 // Check "super" completion as a message receiver.
 // RUN: c-index-test -code-completion-at=%s:20:4 %s | FileCheck -check-prefix=CHECK-ADD-RECEIVER %s
 // CHECK-ADD-RECEIVER: ObjCInstanceMethodDecl:{ResultType void}{TypedText super}{HorizontalSpace  }{Text add:}{Placeholder a}{HorizontalSpace  }{Text to:}{Placeholder b} (20)
@@ -59,3 +72,10 @@
 // RUN: c-index-test -code-completion-at=%s:25:10 %s | FileCheck -check-prefix=CHECK-SELECTOR-SELECTOR %s
 // RUN: c-index-test -code-completion-at=%s:25:28 %s | FileCheck -check-prefix=CHECK-SELECTOR-FIRST %s
 // RUN: c-index-test -code-completion-at=%s:25:37 %s | FileCheck -check-prefix=CHECK-SELECTOR-SECOND %s
+
+// Check "super" completion for a method declared in a category.
+// RUN: c-index-test -code-completion-at=%s:38:10 %s | FileCheck -check-prefix=CHECK-IN-CATEGORY %s
+// CHECK-IN-CATEGORY: ObjCInstanceMethodDecl:{ResultType void}{TypedText add:}{Placeholder (int)}{HorizontalSpace  }{TypedText to:}{Placeholder (int)} (35)
+// CHECK-IN-CATEGORY: ObjCInstanceMethodDecl:{ResultType void}{TypedText last} (35)
+// CHECK-IN-CATEGORY: ObjCInstanceMethodDecl:{ResultType void}{TypedText multiply:}{Placeholder a}{HorizontalSpace  }{Text by:}{Placeholder b} (20)
+





More information about the cfe-commits mailing list