blob: 9e52d93e5701763cbeb67fe3f001e055c01f9d86 [file] [log] [blame]
Douglas Gregore8f5a172010-04-07 00:21:17 +00001/* Note: the RUN lines are near the end of the file, since line/column
2 matter for this test. */
Douglas Gregorafc45782011-02-15 22:19:42 +00003#define IBAction void
Douglas Gregore8f5a172010-04-07 00:21:17 +00004@protocol P1
5- (id)abc;
6- (id)initWithInt:(int)x;
Douglas Gregor90f5f472012-04-10 18:35:07 +00007- (id)initWithTwoInts:(inout int)x second:(int)y;
Douglas Gregore8f5a172010-04-07 00:21:17 +00008- (int)getInt;
9- (id)getSelf;
10@end
Douglas Gregorb92a4082012-06-12 13:44:08 +000011@protocol P1;
Douglas Gregore8f5a172010-04-07 00:21:17 +000012@protocol P2<P1>
13+ (id)alloc;
14@end
15
16@interface A <P1>
17- (id)init;
18- (int)getValue;
19@end
20
21@interface B : A<P2>
22- (id)initWithInt:(int)x;
23- (int)getSecondValue;
24- (id)getSelf;
25- (int)setValue:(int)x;
26@end
27
28@interface B (FooBar)
29- (id)categoryFunction:(int)x;
30@end
31
32@implementation B
33- (int)getSecondValue { return 0; }
34- (id)init { return self; }
35- (id)getSelf { return self; }
36- (void)setValue:(int)x { }
37- (id)initWithTwoInts:(int)x second:(int)y { return self; }
38+ (id)alloc { return 0; }
39@end
40
41@implementation B (FooBar)
42- (id)categoryFunction:(int)x { return self; }
43@end
44
Douglas Gregor1f5537a2010-07-08 23:20:03 +000045@interface C
46- (int)first:(int)x second:(float)y third:(double)z;
Douglas Gregor40ed9a12010-07-08 23:37:41 +000047- (id)first:(int)xx second2:(float)y2 third:(double)z;
48- (void*)first:(int)xxx second3:(float)y3 third:(double)z;
Douglas Gregor1f5537a2010-07-08 23:20:03 +000049@end
50
51@interface D
Douglas Gregor40ed9a12010-07-08 23:37:41 +000052- (int)first:(int)x second2:(float)y third:(double)z;
Douglas Gregor1f5537a2010-07-08 23:20:03 +000053@end
54
Douglas Gregor47c03a72010-08-17 15:53:35 +000055@implementation D
Douglas Gregord32b0222010-08-24 01:06:58 +000056- (int)first:(int)x second2:(float)y third:(double)z { }
57@end
58
59@interface Passing
Douglas Gregor90f5f472012-04-10 18:35:07 +000060- (oneway void)method:(in id)x;
Douglas Gregor47c03a72010-08-17 15:53:35 +000061@end
62
Douglas Gregor813d8342011-02-18 22:29:55 +000063@interface Gaps
64- (void)method:(int)x :(int)y;
65@end
66
67@implementation Gaps
Douglas Gregor90f5f472012-04-10 18:35:07 +000068- (void)method:(int)x :(int)y {}
69@end
70
71@implementation Passing
72- (oneway void)method:(in id x) {}
Douglas Gregor813d8342011-02-18 22:29:55 +000073@end
74
Douglas Gregore8f5a172010-04-07 00:21:17 +000075// RUN: c-index-test -code-completion-at=%s:17:3 %s | FileCheck -check-prefix=CHECK-CC1 %s
Argyrios Kyrtzidis526d2442012-09-26 16:39:56 +000076// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText abc} (40)
77// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getInt} (40)
78// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf} (40)
79// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x} (40)
80// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y} (40)
Douglas Gregore8f5a172010-04-07 00:21:17 +000081// RUN: c-index-test -code-completion-at=%s:17:7 %s | FileCheck -check-prefix=CHECK-CC2 %s
Douglas Gregor16ed9ad2010-08-17 16:06:07 +000082// CHECK-CC2: ObjCInstanceMethodDecl:{TypedText abc}
83// CHECK-CC2-NEXT: ObjCInstanceMethodDecl:{TypedText getSelf}
Douglas Gregorc7b7b7a2010-10-18 21:05:04 +000084// CHECK-CC2: ObjCInstanceMethodDecl:{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}
Douglas Gregor90f5f472012-04-10 18:35:07 +000085// CHECK-CC2: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}
Douglas Gregore8f5a172010-04-07 00:21:17 +000086// RUN: c-index-test -code-completion-at=%s:24:7 %s | FileCheck -check-prefix=CHECK-CC3 %s
Douglas Gregor16ed9ad2010-08-17 16:06:07 +000087// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText abc}
88// CHECK-CC3-NEXT: ObjCInstanceMethodDecl:{TypedText getSelf}
89// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText init}
Douglas Gregorc7b7b7a2010-10-18 21:05:04 +000090// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}
Douglas Gregor90f5f472012-04-10 18:35:07 +000091// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}
Douglas Gregor32be4a52010-10-11 21:37:58 +000092// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:33:3 %s | FileCheck -check-prefix=CHECK-CC4 %s
Douglas Gregor8ec904c2010-10-19 00:03:23 +000093// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText abc}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (42)
Douglas Gregor16ed9ad2010-08-17 16:06:07 +000094// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getInt}{HorizontalSpace }{LeftBrace {}{VerticalSpace
95// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getSecondValue}{HorizontalSpace }{LeftBrace {}{VerticalSpace
Douglas Gregor8ec904c2010-10-19 00:03:23 +000096// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (40)
Douglas Gregorc7b7b7a2010-10-18 21:05:04 +000097// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace
Douglas Gregor90f5f472012-04-10 18:35:07 +000098// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace }{LeftBrace {}{VerticalSpace
Douglas Gregorc7b7b7a2010-10-18 21:05:04 +000099// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText setValue}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace
Douglas Gregor32be4a52010-10-11 21:37:58 +0000100// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:33:8 %s | FileCheck -check-prefix=CHECK-CC5 %s
Argyrios Kyrtzidis526d2442012-09-26 16:39:56 +0000101// CHECK-CC5: ObjCInstanceMethodDecl:{TypedText getInt}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (42)
102// CHECK-CC5: ObjCInstanceMethodDecl:{TypedText getSecondValue}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (40)
Douglas Gregore8f5a172010-04-07 00:21:17 +0000103// CHECK-CC5-NOT: {TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace
Douglas Gregorc7b7b7a2010-10-18 21:05:04 +0000104// CHECK-CC5: ObjCInstanceMethodDecl:{TypedText setValue}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace
Douglas Gregor32be4a52010-10-11 21:37:58 +0000105// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:37:7 %s | FileCheck -check-prefix=CHECK-CC6 %s
Douglas Gregor16ed9ad2010-08-17 16:06:07 +0000106// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText abc}{HorizontalSpace }{LeftBrace {}{VerticalSpace
Douglas Gregor8ec904c2010-10-19 00:03:23 +0000107// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (40)
Douglas Gregorc7b7b7a2010-10-18 21:05:04 +0000108// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText initWithInt}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace
Douglas Gregor90f5f472012-04-10 18:35:07 +0000109// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{TypedText :}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace }{LeftBrace {}{VerticalSpace
Douglas Gregor32be4a52010-10-11 21:37:58 +0000110// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:42:3 %s | FileCheck -check-prefix=CHECK-CC7 %s
Douglas Gregor8ec904c2010-10-19 00:03:23 +0000111// CHECK-CC7: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText abc}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (42)
Douglas Gregorc7b7b7a2010-10-18 21:05:04 +0000112// CHECK-CC7: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText categoryFunction}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace
Douglas Gregor8ec904c2010-10-19 00:03:23 +0000113// CHECK-CC7: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (42)
Douglas Gregor32be4a52010-10-11 21:37:58 +0000114// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:52:21 %s | FileCheck -check-prefix=CHECK-CC8 %s
Douglas Gregor8ec904c2010-10-19 00:03:23 +0000115// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType id}{Informative first:}{TypedText second2:}{Text (float)y2}{HorizontalSpace }{TypedText third:}{Text (double)z} (35)
116// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType void *}{Informative first:}{TypedText second3:}{Text (float)y3}{HorizontalSpace }{TypedText third:}{Text (double)z} (35)
117// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative first:}{TypedText second:}{Text (float)y}{HorizontalSpace }{TypedText third:}{Text (double)z} (8)
Douglas Gregor32be4a52010-10-11 21:37:58 +0000118// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:52:19 %s | FileCheck -check-prefix=CHECK-CC9 %s
Douglas Gregor8ec904c2010-10-19 00:03:23 +0000119// CHECK-CC9: NotImplemented:{TypedText x} (40)
120// CHECK-CC9: NotImplemented:{TypedText xx} (40)
121// CHECK-CC9: NotImplemented:{TypedText xxx} (40)
Douglas Gregor32be4a52010-10-11 21:37:58 +0000122// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:52:36 %s | FileCheck -check-prefix=CHECK-CCA %s
Douglas Gregor8ec904c2010-10-19 00:03:23 +0000123// CHECK-CCA: NotImplemented:{TypedText y2} (40)
Douglas Gregor47c03a72010-08-17 15:53:35 +0000124// RUN: c-index-test -code-completion-at=%s:56:3 %s | FileCheck -check-prefix=CHECK-CCB %s
Douglas Gregor8ec904c2010-10-19 00:03:23 +0000125// CHECK-CCB: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText first}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second2:}{LeftParen (}{Text float}{RightParen )}{Text y}{HorizontalSpace }{TypedText third:}{LeftParen (}{Text double}{RightParen )}{Text z} (40)
Douglas Gregor47c03a72010-08-17 15:53:35 +0000126// RUN: c-index-test -code-completion-at=%s:56:8 %s | FileCheck -check-prefix=CHECK-CCC %s
Douglas Gregor8ec904c2010-10-19 00:03:23 +0000127// CHECK-CCC: ObjCInstanceMethodDecl:{TypedText first}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second2:}{LeftParen (}{Text float}{RightParen )}{Text y}{HorizontalSpace }{TypedText third:}{LeftParen (}{Text double}{RightParen )}{Text z} (40)
Douglas Gregor47c03a72010-08-17 15:53:35 +0000128// RUN: c-index-test -code-completion-at=%s:56:21 %s | FileCheck -check-prefix=CHECK-CCD %s
Douglas Gregor8ec904c2010-10-19 00:03:23 +0000129// CHECK-CCD: ObjCInstanceMethodDecl:{ResultType id}{Informative first:}{TypedText second2:}{Text (float)y2}{HorizontalSpace }{TypedText third:}{Text (double)z} (35)
130// CHECK-CCD: ObjCInstanceMethodDecl:{ResultType int}{Informative first:}{TypedText second2:}{Text (float)y}{HorizontalSpace }{TypedText third:}{Text (double)z} (8)
131// CHECK-CCD: ObjCInstanceMethodDecl:{ResultType void *}{Informative first:}{TypedText second3:}{Text (float)y3}{HorizontalSpace }{TypedText third:}{Text (double)z} (35)
132// CHECK-CCD: ObjCInstanceMethodDecl:{ResultType int}{Informative first:}{TypedText second:}{Text (float)y}{HorizontalSpace }{TypedText third:}{Text (double)z} (8)
Douglas Gregor47c03a72010-08-17 15:53:35 +0000133// RUN: c-index-test -code-completion-at=%s:56:38 %s | FileCheck -check-prefix=CHECK-CCE %s
Douglas Gregor8ec904c2010-10-19 00:03:23 +0000134// CHECK-CCE: ObjCInstanceMethodDecl:{ResultType id}{Informative first:}{Informative second2:}{TypedText third:}{Text (double)z} (35)
135// CHECK-CCE: ObjCInstanceMethodDecl:{ResultType int}{Informative first:}{Informative second2:}{TypedText third:}{Text (double)z} (8)
Douglas Gregord32b0222010-08-24 01:06:58 +0000136// RUN: c-index-test -code-completion-at=%s:60:4 %s | FileCheck -check-prefix=CHECK-CCF %s
Douglas Gregor08f43cd2010-09-20 23:11:55 +0000137// CHECK-CCF: ObjCInterfaceDecl:{TypedText A} (50)
138// CHECK-CCF: ObjCInterfaceDecl:{TypedText B} (50)
Douglas Gregor8ec904c2010-10-19 00:03:23 +0000139// CHECK-CCF: NotImplemented:{TypedText bycopy} (40)
140// CHECK-CCF: NotImplemented:{TypedText byref} (40)
141// CHECK-CCF: NotImplemented:{TypedText in} (40)
142// CHECK-CCF: NotImplemented:{TypedText inout} (40)
143// CHECK-CCF: NotImplemented:{TypedText oneway} (40)
144// CHECK-CCF: NotImplemented:{TypedText out} (40)
Douglas Gregor08f43cd2010-09-20 23:11:55 +0000145// CHECK-CCF: NotImplemented:{TypedText unsigned} (50)
146// CHECK-CCF: NotImplemented:{TypedText void} (50)
147// CHECK-CCF: NotImplemented:{TypedText volatile} (50)
Douglas Gregord32b0222010-08-24 01:06:58 +0000148// RUN: c-index-test -code-completion-at=%s:60:11 %s | FileCheck -check-prefix=CHECK-CCG %s
Douglas Gregor08f43cd2010-09-20 23:11:55 +0000149// CHECK-CCG: ObjCInterfaceDecl:{TypedText A} (50)
150// CHECK-CCG: ObjCInterfaceDecl:{TypedText B} (50)
Douglas Gregor8ec904c2010-10-19 00:03:23 +0000151// CHECK-CCG-NOT: NotImplemented:{TypedText bycopy} (40)
152// CHECK-CCG-NOT: NotImplemented:{TypedText byref} (40)
153// CHECK-CCG: NotImplemented:{TypedText in} (40)
154// CHECK-CCG: NotImplemented:{TypedText inout} (40)
155// CHECK-CCG-NOT: NotImplemented:{TypedText oneway} (40)
156// CHECK-CCG: NotImplemented:{TypedText out} (40)
Douglas Gregor08f43cd2010-09-20 23:11:55 +0000157// CHECK-CCG: NotImplemented:{TypedText unsigned} (50)
158// CHECK-CCG: NotImplemented:{TypedText void} (50)
159// CHECK-CCG: NotImplemented:{TypedText volatile} (50)
Douglas Gregord32b0222010-08-24 01:06:58 +0000160// RUN: c-index-test -code-completion-at=%s:60:24 %s | FileCheck -check-prefix=CHECK-CCF %s
161// RUN: c-index-test -code-completion-at=%s:60:26 %s | FileCheck -check-prefix=CHECK-CCH %s
Douglas Gregor08f43cd2010-09-20 23:11:55 +0000162// CHECK-CCH: ObjCInterfaceDecl:{TypedText A} (50)
163// CHECK-CCH: ObjCInterfaceDecl:{TypedText B} (50)
Douglas Gregor8ec904c2010-10-19 00:03:23 +0000164// CHECK-CCH: NotImplemented:{TypedText bycopy} (40)
165// CHECK-CCH: NotImplemented:{TypedText byref} (40)
166// CHECK-CCH-NOT: NotImplemented:{TypedText in} (40)
167// CHECK-CCH: NotImplemented:{TypedText inout} (40)
168// CHECK-CCH: NotImplemented:{TypedText oneway} (40)
169// CHECK-CCH: NotImplemented:{TypedText out} (40)
Douglas Gregor08f43cd2010-09-20 23:11:55 +0000170// CHECK-CCH: NotImplemented:{TypedText unsigned} (50)
171// CHECK-CCH: NotImplemented:{TypedText void} (50)
172// CHECK-CCH: NotImplemented:{TypedText volatile} (50)
Douglas Gregorafc45782011-02-15 22:19:42 +0000173
174// IBAction completion
175// RUN: c-index-test -code-completion-at=%s:5:4 %s | FileCheck -check-prefix=CHECK-IBACTION %s
176// CHECK-IBACTION: NotImplemented:{TypedText IBAction}{RightParen )}{Placeholder selector}{Colon :}{LeftParen (}{Text id}{RightParen )}{Text sender} (40)
177
Douglas Gregor813d8342011-02-18 22:29:55 +0000178// <rdar://problem/8939352>
179// RUN: c-index-test -code-completion-at=%s:68:9 %s | FileCheck -check-prefix=CHECK-8939352 %s
180// CHECK-8939352: ObjCInstanceMethodDecl:{TypedText method}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text y} (40)
Douglas Gregor90f5f472012-04-10 18:35:07 +0000181
182
183// RUN: c-index-test -code-completion-at=%s:72:2 %s | FileCheck -check-prefix=CHECK-ONEWAY %s
Argyrios Kyrtzidis526d2442012-09-26 16:39:56 +0000184// CHECK-ONEWAY: ObjCInstanceMethodDecl:{LeftParen (}{Text oneway }{Text void}{RightParen )}{TypedText method}{TypedText :}{LeftParen (}{Text in }{Text id}{RightParen )}{Text x} (40)