diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-09-16 15:34:59 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-09-16 15:34:59 +0000 |
commit | e396c7bd99ed99fd8136fadc8945791754c61b16 (patch) | |
tree | b287320040ba43c06a32c78f27118f13ea7dcd7a | |
parent | c7b6d883360092808b0ae81b7829fa8196ef42a1 (diff) |
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
-rw-r--r-- | lib/Sema/SemaCodeComplete.cpp | 11 | ||||
-rw-r--r-- | test/Index/complete-objc-message-id.m | 20 |
2 files changed, 31 insertions, 0 deletions
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<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; 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 <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) |