From: Douglas Gregor Date: Thu, 16 Sep 2010 15:34:59 +0000 (+0000) Subject: When collecting Objective-C methods for message send completions, be X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e396c7bd99ed99fd8136fadc8945791754c61b16;p=clang When collecting Objective-C methods for message send completions, be sure to visit the protocols of protocols. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114079 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index 3ec68029b2..615d126fb3 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -3869,6 +3869,17 @@ static void AddObjCMethods(ObjCContainerDecl *Container, } } + // Visit the protocols of protocols. + if (ObjCProtocolDecl *Protocol = dyn_cast(Container)) { + const ObjCList &Protocols + = Protocol->getReferencedProtocols(); + for (ObjCList::iterator I = Protocols.begin(), + E = Protocols.end(); + I != E; ++I) + AddObjCMethods(*I, WantInstanceMethods, WantKind, SelIdents, NumSelIdents, + CurContext, Results, false); + } + ObjCInterfaceDecl *IFace = dyn_cast(Container); if (!IFace) return; diff --git a/test/Index/complete-objc-message-id.m b/test/Index/complete-objc-message-id.m index be42b9b855..f5be31fa60 100644 --- a/test/Index/complete-objc-message-id.m +++ b/test/Index/complete-objc-message-id.m @@ -31,6 +31,22 @@ void message_id(B *b) { return [A alloc]; } @end + +@protocol P1 +- (int)P1_method1; ++ (int)P1_method2; +@end + +@protocol P2 +- (int)P2_method1; ++ (int)P2_method2; +@end + +void message_qualified_id(id 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)