]> granicus.if.org Git - clang/commitdiff
When collecting Objective-C methods for message send completions, be
authorDouglas Gregor <dgregor@apple.com>
Thu, 16 Sep 2010 15:34:59 +0000 (15:34 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 16 Sep 2010 15:34:59 +0000 (15:34 +0000)
sure to visit the protocols of protocols.

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

lib/Sema/SemaCodeComplete.cpp
test/Index/complete-objc-message-id.m

index 3ec68029b255f9dcdcd0907a6930ba076a4c4af1..615d126fb37c6f36618c92ec8337c795041c19c6 100644 (file)
@@ -3869,6 +3869,17 @@ static void AddObjCMethods(ObjCContainerDecl *Container,
     }
   }
   
+  // Visit the protocols of protocols.
+  if (ObjCProtocolDecl *Protocol = dyn_cast<ObjCProtocolDecl>(Container)) {
+    const ObjCList<ObjCProtocolDecl> &Protocols
+      = Protocol->getReferencedProtocols();
+    for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(),
+                                              E = Protocols.end(); 
+         I != E; ++I)
+      AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, NumSelIdents, 
+                     CurContext, Results, false);    
+  }
+  
   ObjCInterfaceDecl *IFace = dyn_cast<ObjCInterfaceDecl>(Container);
   if (!IFace)
     return;
index be42b9b855efdd1ff0066a180156a8c7284695df..f5be31fa607da83c4636703b2e2b9c87e6b0a31f 100644 (file)
@@ -31,6 +31,22 @@ void message_id(B *b) {
   return [A alloc];
 }
 @end
+
+@protocol P1
+- (int)P1_method1;
++ (int)P1_method2;
+@end
+
+@protocol P2 <P1>
+- (int)P2_method1;
++ (int)P2_method2;
+@end
+
+void message_qualified_id(id<P2> ip2) {
+  [ip2 P1_method];
+   ip2 P1_method];
+}
+
 // RUN: c-index-test -code-completion-at=%s:24:14 %s | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: ObjCInstanceMethodDecl:{ResultType id}{TypedText autorelease}
 // CHECK-CC1-NOT: B_method
@@ -52,3 +68,7 @@ void message_id(B *b) {
 // CHECK-SELECTOR-PREF: ObjCClassMethodDecl:{ResultType id}{TypedText new} (20)
 // CHECK-SELECTOR-PREF: ObjCClassMethodDecl:{ResultType Class}{TypedText superclass} (20)
 
+// RUN: c-index-test -code-completion-at=%s:46:7 %s | FileCheck -check-prefix=CHECK-INSTANCE-QUAL-ID %s
+// RUN: c-index-test -code-completion-at=%s:47:7 %s | FileCheck -check-prefix=CHECK-INSTANCE-QUAL-ID %s
+// CHECK-INSTANCE-QUAL-ID: ObjCInstanceMethodDecl:{ResultType int}{TypedText P1_method1} (22)
+// CHECK-INSTANCE-QUAL-ID: ObjCInstanceMethodDecl:{ResultType int}{TypedText P2_method1} (20)