blob: 54f62a045db3b9cd432a4844684cf40192623d28 [file] [log] [blame]
Douglas Gregor9630eb62009-11-17 16:44:22 +00001// Note: the run lines follow their respective tests, since line/column
2// matter in this test.
Douglas Gregoraaa107a2010-08-23 23:51:41 +00003#define nil (void*)0
Douglas Gregor9630eb62009-11-17 16:44:22 +00004@protocol FooTestProtocol
5+ protocolClassMethod;
6- protocolInstanceMethod : (int)value;
7@end
8@interface Foo <FooTestProtocol> {
9 void *isa;
10}
11+ (int)classMethod1:a withKeyword:(int)b;
12+ (void)classMethod2;
13+ new;
14- instanceMethod1;
15@end
16
17@interface Foo (FooTestCategory)
18+ categoryClassMethod;
19- categoryInstanceMethod;
20@end
21
22void func() {
23 Foo *obj = [Foo new];
24 [obj xx];
25}
Douglas Gregor24a069f2009-11-17 17:59:40 +000026
27@interface MyClass { }
28+ (int)MyClassMethod:(id)obj;
29- (int)MyInstMethod:(id)x second:(id)y;
30@end
31
32@interface MySubClass : MyClass { }
33+ (int)MySubClassMethod;
34- (int)MySubInstMethod;
35@end
36
37@implementation MyClass
38+ (int)MyClassMethod:(id)obj {
39 return 0;
40}
41
42+ (int)MyPrivateMethod {
43 return 1;
44}
45
46- (int)MyInstMethod:(id)x second:(id)y {
47 return 2;
48}
49
50- (int)MyPrivateInstMethod {
51 return 3;
52}
53@end
Douglas Gregor8e254cf2010-05-27 23:06:34 +000054MyClass *getMyClass();
Douglas Gregor24a069f2009-11-17 17:59:40 +000055@implementation MySubClass
56+ (int)MySubClassMethod {
57 return 2;
58}
59
60+ (int)MySubPrivateMethod {
61 return [super MyPrivateMethod];
62}
63
64- (int)MySubInstMethod:(id)obj {
65 return [super MyInstMethod: obj second:obj];
66}
67
68- (int)MyInstMethod:(id)x second:(id)y {
69 return 3;
70}
71@end
72
73void test_super_var(MySubClass *super) {
74 [super MyInstMethod: super second:super];
75}
76
Douglas Gregorf74a4192009-11-18 00:06:18 +000077@protocol FooTestProtocol2
78- (int)secondProtocolInstanceMethod;
79@end
80
81void test_qual_id(id<FooTestProtocol,FooTestProtocol2> ptr) {
82 [ptr protocolInstanceMethod:1];
83}
84
Douglas Gregord3c68542009-11-19 01:08:35 +000085@interface Overload
86- (int)Method:(int)i;
87- (int)Method;
88- (int)Method:(float)f Arg1:(int)i1 Arg2:(int)i2;
89- (int)Method:(float)f Arg1:(int)i1 OtherArg:(id)obj;
90- (int)Method:(float)f SomeArg:(int)i1 OtherArg:(id)obj;
91- (int)OtherMethod:(float)f Arg1:(int)i1 Arg2:(int)i2;
92@end
93
94void test_overload(Overload *ovl) {
95 [ovl Method:1 Arg1:1 OtherArg:ovl];
96}
97
Douglas Gregor2a17af02009-12-23 00:21:46 +000098@interface Ellipsis
Douglas Gregoraaa107a2010-08-23 23:51:41 +000099- (int)Method:(int)i, ...;
100- (int)SentinelMethod:(int)i, ... __attribute__((sentinel(0,1)));
Douglas Gregor2a17af02009-12-23 00:21:46 +0000101@end
Douglas Gregor2a17af02009-12-23 00:21:46 +0000102void f(Ellipsis *e) {
103 [e Method:1, 2, 3];
104}
105
Douglas Gregor85372b92010-04-06 15:27:03 +0000106@interface Overload2
107+ (int)Method:(int)i;
108+ (int)Method;
109+ (int)Method:(float)f Arg1:(int)i1 Arg2:(int)i2;
110+ (int)Method:(float)f Arg1:(int)i1 OtherArg:(id)obj;
111+ (int)Method:(float)f SomeArg:(int)i1 OtherArg:(id)obj;
112+ (int)OtherMethod:(float)f Arg1:(int)i1 Arg2:(int)i2;
113@end
114
115void test_overload2(void) {
116 [Overload2 Method:1 Arg1:1 OtherArg:ovl];
117}
118
Douglas Gregor13438f92010-04-06 16:40:00 +0000119void msg_id(id x) {
120 [x Method:1 Arg1:1 OtherArg:ovl];
121 [[x blarg] Method:1 Arg1:1 OtherArg:ovl];
122 [id Method:1 Arg1:1 OtherArg:ovl];
123}
124
Douglas Gregor408be5a2010-08-25 01:08:01 +0000125@interface A
126- (void)method1;
127@end
128
129@interface B : A
130- (void)method2;
131@end
132
133void test_ranking(B *b) {
134 [b method1];
135}
136
Douglas Gregor9630eb62009-11-17 16:44:22 +0000137// RUN: c-index-test -code-completion-at=%s:23:19 %s | FileCheck -check-prefix=CHECK-CC1 %s
138// CHECK-CC1: {TypedText categoryClassMethod}
Douglas Gregor834389b2010-01-12 06:38:28 +0000139// CHECK-CC1: {TypedText classMethod1:}{Placeholder (id)a}{HorizontalSpace }{Text withKeyword:}{Placeholder (int)b}
Douglas Gregor9630eb62009-11-17 16:44:22 +0000140// CHECK-CC1: {TypedText classMethod2}
141// CHECK-CC1: {TypedText new}
142// CHECK-CC1: {TypedText protocolClassMethod}
Douglas Gregor9630eb62009-11-17 16:44:22 +0000143// RUN: c-index-test -code-completion-at=%s:24:8 %s | FileCheck -check-prefix=CHECK-CC2 %s
144// CHECK-CC2: {TypedText categoryInstanceMethod}
145// CHECK-CC2: {TypedText instanceMethod1}
146// CHECK-CC2: {TypedText protocolInstanceMethod:}{Placeholder (int)value}
Douglas Gregor24a069f2009-11-17 17:59:40 +0000147// RUN: c-index-test -code-completion-at=%s:61:16 %s | FileCheck -check-prefix=CHECK-CC3 %s
Douglas Gregorff5ce6e2009-12-18 18:53:37 +0000148// CHECK-CC3: ObjCClassMethodDecl:{ResultType int}{TypedText MyClassMethod:}{Placeholder (id)obj}
149// CHECK-CC3: ObjCClassMethodDecl:{ResultType int}{TypedText MyPrivateMethod}
Douglas Gregor24a069f2009-11-17 17:59:40 +0000150// RUN: c-index-test -code-completion-at=%s:65:16 %s | FileCheck -check-prefix=CHECK-CC4 %s
Douglas Gregor834389b2010-01-12 06:38:28 +0000151// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)x}{HorizontalSpace }{Text second:}{Placeholder (id)y}
Douglas Gregorff5ce6e2009-12-18 18:53:37 +0000152// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyPrivateInstMethod}
Douglas Gregor24a069f2009-11-17 17:59:40 +0000153// RUN: c-index-test -code-completion-at=%s:74:9 %s | FileCheck -check-prefix=CHECK-CC5 %s
Douglas Gregor834389b2010-01-12 06:38:28 +0000154// CHECK-CC5: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)x}{HorizontalSpace }{Text second:}{Placeholder (id)y}
Douglas Gregorff5ce6e2009-12-18 18:53:37 +0000155// CHECK-CC5: ObjCInstanceMethodDecl:{ResultType int}{TypedText MySubInstMethod}
Douglas Gregorf74a4192009-11-18 00:06:18 +0000156// RUN: c-index-test -code-completion-at=%s:82:8 %s | FileCheck -check-prefix=CHECK-CC6 %s
Douglas Gregorff5ce6e2009-12-18 18:53:37 +0000157// CHECK-CC6: ObjCInstanceMethodDecl:{ResultType id}{TypedText protocolInstanceMethod:}{Placeholder (int)value}
158// CHECK-CC6: ObjCInstanceMethodDecl:{ResultType int}{TypedText secondProtocolInstanceMethod}
Douglas Gregord3c68542009-11-19 01:08:35 +0000159// RUN: c-index-test -code-completion-at=%s:95:8 %s | FileCheck -check-prefix=CHECK-CC7 %s
Douglas Gregorff5ce6e2009-12-18 18:53:37 +0000160// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method}
161// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i}
Douglas Gregor834389b2010-01-12 06:38:28 +0000162// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2}
163// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj}
164// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj}
165// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2}
Douglas Gregord3c68542009-11-19 01:08:35 +0000166// RUN: c-index-test -code-completion-at=%s:95:17 %s | FileCheck -check-prefix=CHECK-CC8 %s
Douglas Gregorff5ce6e2009-12-18 18:53:37 +0000167// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText }
Douglas Gregor834389b2010-01-12 06:38:28 +0000168// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2}
169// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj}
170// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj}
Douglas Gregord3c68542009-11-19 01:08:35 +0000171// RUN: c-index-test -code-completion-at=%s:95:24 %s | FileCheck -check-prefix=CHECK-CC9 %s
Douglas Gregorff5ce6e2009-12-18 18:53:37 +0000172// CHECK-CC9: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText Arg2:}{Placeholder (int)i2}
173// CHECK-CC9: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText OtherArg:}{Placeholder (id)obj}
Douglas Gregor2a7925c2009-12-07 09:54:55 +0000174// RUN: c-index-test -code-completion-at=%s:61:11 %s | FileCheck -check-prefix=CHECK-CCA %s
Douglas Gregor2a7925c2009-12-07 09:54:55 +0000175// CHECK-CCA: TypedefDecl:{TypedText Class}
Douglas Gregor8e254cf2010-05-27 23:06:34 +0000176// CHECK-CCA-NEXT: ObjCInterfaceDecl:{TypedText Foo}
177// CHECK-CCA-NOT: FunctionDecl:{ResultType void}{TypedText func}{LeftParen (}{RightParen )}
178// CHECK-CCA:FunctionDecl:{ResultType MyClass *}{TypedText getMyClass}{LeftParen (}{RightParen )}
Douglas Gregor2a7925c2009-12-07 09:54:55 +0000179// CHECK-CCA: TypedefDecl:{TypedText id}
180// CHECK-CCA: ObjCInterfaceDecl:{TypedText MyClass}
181// CHECK-CCA: ObjCInterfaceDecl:{TypedText MySubClass}
Douglas Gregorab0b4f12010-01-13 23:24:38 +0000182// CHECK-CCA: {ResultType Class}{TypedText self}
Douglas Gregor2a7925c2009-12-07 09:54:55 +0000183// CHECK-CCA: {TypedText super}
Douglas Gregor2a17af02009-12-23 00:21:46 +0000184// RUN: c-index-test -code-completion-at=%s:103:6 %s | FileCheck -check-prefix=CHECK-CCB %s
185// CHECK-CCB: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i}{Placeholder , ...}
Douglas Gregoraaa107a2010-08-23 23:51:41 +0000186// CHECK-CCB: ObjCInstanceMethodDecl:{ResultType int}{TypedText SentinelMethod:}{Placeholder (int)i}{Placeholder , ...}{Text , nil}
Douglas Gregor85372b92010-04-06 15:27:03 +0000187// RUN: c-index-test -code-completion-at=%s:116:14 %s | FileCheck -check-prefix=CHECK-CCC %s
188// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method}
189// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i}
190// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2}
191// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj}
192// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj}
193// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2}
194// RUN: c-index-test -code-completion-at=%s:116:23 %s | FileCheck -check-prefix=CHECK-CCD %s
195// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText }
196// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2}
197// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj}
198// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj}
199// RUN: c-index-test -code-completion-at=%s:116:30 %s | FileCheck -check-prefix=CHECK-CCE %s
200// CHECK-CCE: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText Arg2:}{Placeholder (int)i2}
201// CHECK-CCE: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText OtherArg:}{Placeholder (id)obj}
202// RUN: c-index-test -code-completion-at=%s:61:11 %s | FileCheck -check-prefix=CHECK-CCF %s
Douglas Gregor85372b92010-04-06 15:27:03 +0000203// CHECK-CCF: TypedefDecl:{TypedText Class}
204// CHECK-CCF: ObjCInterfaceDecl:{TypedText Foo}
Douglas Gregor8e254cf2010-05-27 23:06:34 +0000205// CHECK-CCF-NOT: FunctionDecl:{ResultType void}{TypedText func}{LeftParen (}{RightParen )}
Douglas Gregor85372b92010-04-06 15:27:03 +0000206// CHECK-CCF: TypedefDecl:{TypedText id}
207// CHECK-CCF: ObjCInterfaceDecl:{TypedText MyClass}
208// CHECK-CCF: ObjCInterfaceDecl:{TypedText MySubClass}
Douglas Gregor85372b92010-04-06 15:27:03 +0000209// CHECK-CCF: {ResultType Class}{TypedText self}
210// CHECK-CCF: {TypedText super}
Douglas Gregor13438f92010-04-06 16:40:00 +0000211// RUN: c-index-test -code-completion-at=%s:120:6 %s | FileCheck -check-prefix=CHECK-CCG %s
212// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType id}{TypedText categoryInstanceMethod}
213// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType id}{TypedText instanceMethod1}
214// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method}
215// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i}
216// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2}
217// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj}
218// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj}
219// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)x}{HorizontalSpace }{Text second:}{Placeholder (id)y}
220// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyPrivateInstMethod}
221// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText MySubInstMethod}
222// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText MySubInstMethod:}{Placeholder (id)obj}
223// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2}
224// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType id}{TypedText protocolInstanceMethod:}{Placeholder (int)value}
225// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText secondProtocolInstanceMethod}
226// RUN: c-index-test -code-completion-at=%s:121:14 %s | FileCheck -check-prefix=CHECK-CCG %s
227// RUN: c-index-test -code-completion-at=%s:122:7 %s | FileCheck -check-prefix=CHECK-CCH %s
228// CHECK-CCH: ObjCClassMethodDecl:{ResultType id}{TypedText categoryClassMethod}
229// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod1:}{Placeholder (id)a}{HorizontalSpace }{Text withKeyword:}{Placeholder (int)b}
230// CHECK-CCH: ObjCClassMethodDecl:{ResultType void}{TypedText classMethod2}
231// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method}
232// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i}
233// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2}
234// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj}
235// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj}
236// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MyClassMethod:}{Placeholder (id)obj}
237// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MyPrivateMethod}
238// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MySubClassMethod}
239// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MySubPrivateMethod}
240// CHECK-CCH: ObjCClassMethodDecl:{ResultType id}{TypedText new}
241// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2}
242// CHECK-CCH: ObjCClassMethodDecl:{ResultType id}{TypedText protocolClassMethod}
Douglas Gregor408be5a2010-08-25 01:08:01 +0000243// RUN: c-index-test -code-completion-at=%s:134:6 %s | FileCheck -check-prefix=CHECK-CCI %s
244// CHECK-CCI: ObjCInstanceMethodDecl:{ResultType void}{TypedText method1} (22)
245// CHECK-CCI: ObjCInstanceMethodDecl:{ResultType void}{TypedText method2} (20)