xref: /minix3/external/bsd/llvm/dist/clang/test/Index/c-index-getCursor-test.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fblocks -emit-pch -x objective-c %s -detailed-preprocessing-record -o %t.ast
2*f4a2713aSLionel Sambuc// RUN: c-index-test -test-file-scan %t.ast %s > %t 2>&1 && FileCheck --input-file=%t %s
3*f4a2713aSLionel Sambuc@interface Foo
4*f4a2713aSLionel Sambuc{
5*f4a2713aSLionel Sambuc}
6*f4a2713aSLionel Sambuc
7*f4a2713aSLionel Sambuc- foo;
8*f4a2713aSLionel Sambuc+ fooC;
9*f4a2713aSLionel Sambuc
10*f4a2713aSLionel Sambuc@end
11*f4a2713aSLionel Sambuc
12*f4a2713aSLionel Sambuc@interface Bar : Foo
13*f4a2713aSLionel Sambuc{
14*f4a2713aSLionel Sambuc}
15*f4a2713aSLionel Sambuc
16*f4a2713aSLionel Sambuc@end
17*f4a2713aSLionel Sambuc
18*f4a2713aSLionel Sambuc@interface Foo (FooCat)
19*f4a2713aSLionel Sambuc- (int) catMethodWithFloat:(float) fArg;
20*f4a2713aSLionel Sambuc- (float) floatMethod;
21*f4a2713aSLionel Sambuc@end
22*f4a2713aSLionel Sambuc
23*f4a2713aSLionel Sambuc@protocol Proto
24*f4a2713aSLionel Sambuc- pMethod;
25*f4a2713aSLionel Sambuc@end
26*f4a2713aSLionel Sambuc
27*f4a2713aSLionel Sambuc@protocol SubP <Proto>
28*f4a2713aSLionel Sambuc- spMethod;
29*f4a2713aSLionel Sambuc@end
30*f4a2713aSLionel Sambuc
31*f4a2713aSLionel Sambuc@interface Baz : Bar <SubP>
32*f4a2713aSLionel Sambuc{
33*f4a2713aSLionel Sambuc    int _anIVar;
34*f4a2713aSLionel Sambuc}
35*f4a2713aSLionel Sambuc
36*f4a2713aSLionel Sambuc- (Foo *) bazMethod;
37*f4a2713aSLionel Sambuc
38*f4a2713aSLionel Sambuc@end
39*f4a2713aSLionel Sambuc
40*f4a2713aSLionel Sambucenum {
41*f4a2713aSLionel Sambuc  someEnum
42*f4a2713aSLionel Sambuc};
43*f4a2713aSLionel Sambuc
44*f4a2713aSLionel Sambucint main (int argc, const char * argv[]) {
45*f4a2713aSLionel Sambuc	Baz * bee;
46*f4a2713aSLionel Sambuc	id a = [bee foo];
47*f4a2713aSLionel Sambuc	id <SubP> c = [Foo fooC];
48*f4a2713aSLionel Sambuc	id <Proto> d;
49*f4a2713aSLionel Sambuc	d = c;
50*f4a2713aSLionel Sambuc	[d pMethod];
51*f4a2713aSLionel Sambuc	[bee catMethodWithFloat:[bee floatMethod]];
52*f4a2713aSLionel Sambuc  main(someEnum, (const char **)bee);
53*f4a2713aSLionel Sambuc}
54*f4a2713aSLionel Sambuc
55*f4a2713aSLionel Sambuc#define CONCAT(X, Y) X##Y
56*f4a2713aSLionel Sambuc
57*f4a2713aSLionel Sambucvoid f() {
58*f4a2713aSLionel Sambuc   int CONCAT(my,_var);
59*f4a2713aSLionel Sambuc}
60*f4a2713aSLionel Sambuc#undef CONCAT
61*f4a2713aSLionel Sambuc
62*f4a2713aSLionel Sambuc// CHECK: [1:1 - 3:1] Invalid Cursor => NoDeclFound
63*f4a2713aSLionel Sambuc// CHECK: [3:1 - 7:1] ObjCInterfaceDecl=Foo:3:12
64*f4a2713aSLionel Sambuc// CHECK: [7:1 - 7:7] ObjCInstanceMethodDecl=foo:7:3
65*f4a2713aSLionel Sambuc// CHECK: [7:7 - 8:1] ObjCInterfaceDecl=Foo:3:12
66*f4a2713aSLionel Sambuc// CHECK: [8:1 - 8:8] ObjCClassMethodDecl=fooC:8:3
67*f4a2713aSLionel Sambuc// CHECK: [8:8 - 10:5] ObjCInterfaceDecl=Foo:3:12
68*f4a2713aSLionel Sambuc// CHECK: [10:5 - 12:1] Invalid Cursor => NoDeclFound
69*f4a2713aSLionel Sambuc// CHECK: [12:1 - 12:18] ObjCInterfaceDecl=Bar:12:12
70*f4a2713aSLionel Sambuc// CHECK: [12:18 - 12:21] ObjCSuperClassRef=Foo:3:12
71*f4a2713aSLionel Sambuc// CHECK: [12:21 - 16:5] ObjCInterfaceDecl=Bar:12:12
72*f4a2713aSLionel Sambuc// CHECK: [16:5 - 18:1] Invalid Cursor => NoDeclFound
73*f4a2713aSLionel Sambuc// CHECK: [18:1 - 18:12] ObjCCategoryDecl=FooCat:18:12
74*f4a2713aSLionel Sambuc// CHECK: [18:12 - 18:15] ObjCClassRef=Foo:3:12
75*f4a2713aSLionel Sambuc// CHECK: [18:15 - 19:1] ObjCCategoryDecl=FooCat:18:12
76*f4a2713aSLionel Sambuc// CHECK: [19:1 - 19:29] ObjCInstanceMethodDecl=catMethodWithFloat::19:9
77*f4a2713aSLionel Sambuc// CHECK: [19:29 - 19:40] ParmDecl=fArg:19:36 (Definition)
78*f4a2713aSLionel Sambuc// CHECK: [19:40 - 19:41] ObjCInstanceMethodDecl=catMethodWithFloat::19:9
79*f4a2713aSLionel Sambuc// CHECK: [19:41 - 20:1] ObjCCategoryDecl=FooCat:18:12
80*f4a2713aSLionel Sambuc// CHECK: [20:1 - 20:23] ObjCInstanceMethodDecl=floatMethod:20:11
81*f4a2713aSLionel Sambuc// CHECK: [20:23 - 21:5] ObjCCategoryDecl=FooCat:18:12
82*f4a2713aSLionel Sambuc// CHECK: [21:5 - 23:1] Invalid Cursor => NoDeclFound
83*f4a2713aSLionel Sambuc// CHECK: [23:1 - 24:1] ObjCProtocolDecl=Proto:23:11 (Definition)
84*f4a2713aSLionel Sambuc// CHECK: [24:1 - 24:11] ObjCInstanceMethodDecl=pMethod:24:3
85*f4a2713aSLionel Sambuc// CHECK: [24:11 - 25:5] ObjCProtocolDecl=Proto:23:11 (Definition)
86*f4a2713aSLionel Sambuc// CHECK: [25:5 - 27:1] Invalid Cursor => NoDeclFound
87*f4a2713aSLionel Sambuc// CHECK: [27:1 - 27:17] ObjCProtocolDecl=SubP:27:11 (Definition)
88*f4a2713aSLionel Sambuc// CHECK: [27:17 - 27:22] ObjCProtocolRef=Proto:23:1
89*f4a2713aSLionel Sambuc// CHECK: [27:22 - 28:1] ObjCProtocolDecl=SubP:27:11 (Definition)
90*f4a2713aSLionel Sambuc// CHECK: [28:1 - 28:12] ObjCInstanceMethodDecl=spMethod:28:3
91*f4a2713aSLionel Sambuc// CHECK: [28:12 - 29:5] ObjCProtocolDecl=SubP:27:11 (Definition)
92*f4a2713aSLionel Sambuc// CHECK: [29:5 - 31:1] Invalid Cursor => NoDeclFound
93*f4a2713aSLionel Sambuc// CHECK: [31:1 - 31:18] ObjCInterfaceDecl=Baz:31:12
94*f4a2713aSLionel Sambuc// CHECK: [31:18 - 31:21] ObjCSuperClassRef=Bar:12:12
95*f4a2713aSLionel Sambuc// CHECK: [31:21 - 31:23] ObjCInterfaceDecl=Baz:31:12
96*f4a2713aSLionel Sambuc// CHECK: [31:23 - 31:27] ObjCProtocolRef=SubP:27:1
97*f4a2713aSLionel Sambuc// CHECK: [31:27 - 33:5] ObjCInterfaceDecl=Baz:31:12
98*f4a2713aSLionel Sambuc// CHECK: [33:5 - 33:16] ObjCIvarDecl=_anIVar:33:9 (Definition)
99*f4a2713aSLionel Sambuc// CHECK: [33:16 - 36:1] ObjCInterfaceDecl=Baz:31:12
100*f4a2713aSLionel Sambuc// CHECK: [36:1 - 36:4] ObjCInstanceMethodDecl=bazMethod:36:1
101*f4a2713aSLionel Sambuc// CHECK: [36:4 - 36:7] ObjCClassRef=Foo:3:12
102*f4a2713aSLionel Sambuc// CHECK: [36:7 - 36:21] ObjCInstanceMethodDecl=bazMethod:36:1
103*f4a2713aSLionel Sambuc// CHECK: [36:21 - 38:5] ObjCInterfaceDecl=Baz:31:12
104*f4a2713aSLionel Sambuc// CHECK: [38:5 - 40:1] Invalid Cursor => NoDeclFound
105*f4a2713aSLionel Sambuc// CHECK: [40:1 - 41:3] EnumDecl=:40:1 (Definition)
106*f4a2713aSLionel Sambuc// CHECK: [41:3 - 41:11] EnumConstantDecl=someEnum:41:3 (Definition)
107*f4a2713aSLionel Sambuc// CHECK: [41:11 - 42:2] EnumDecl=:40:1 (Definition)
108*f4a2713aSLionel Sambuc// CHECK: [42:2 - 44:1] Invalid Cursor => NoDeclFound
109*f4a2713aSLionel Sambuc// CHECK: [44:1 - 44:11] FunctionDecl=main:44:5 (Definition)
110*f4a2713aSLionel Sambuc// CHECK: [44:11 - 44:19] ParmDecl=argc:44:15 (Definition)
111*f4a2713aSLionel Sambuc// CHECK: [44:19 - 44:21] FunctionDecl=main:44:5 (Definition)
112*f4a2713aSLionel Sambuc// CHECK: [44:21 - 44:40] ParmDecl=argv:44:34 (Definition)
113*f4a2713aSLionel Sambuc// CHECK: [44:40 - 44:42] FunctionDecl=main:44:5 (Definition)
114*f4a2713aSLionel Sambuc// CHECK: [44:42 - 45:2] CompoundStmt=
115*f4a2713aSLionel Sambuc// CHECK: [45:2 - 45:5] ObjCClassRef=Baz:31:12
116*f4a2713aSLionel Sambuc// CHECK: [45:5 - 45:11] VarDecl=bee:45:8 (Definition)
117*f4a2713aSLionel Sambuc// CHECK: [45:11 - 45:12] DeclStmt=
118*f4a2713aSLionel Sambuc// CHECK: [45:12 - 46:2] CompoundStmt=
119*f4a2713aSLionel Sambuc// CHECK: [46:2 - 46:4] TypeRef=id:0:0
120*f4a2713aSLionel Sambuc// CHECK: [46:4 - 46:9] VarDecl=a:46:5 (Definition)
121*f4a2713aSLionel Sambuc// CHECK: [46:9 - 46:10] ObjCMessageExpr=foo:7:3
122*f4a2713aSLionel Sambuc// CHECK: [46:10 - 46:13] DeclRefExpr=bee:45:8
123*f4a2713aSLionel Sambuc// CHECK: [46:13 - 46:18] ObjCMessageExpr=foo:7:3
124*f4a2713aSLionel Sambuc// CHECK: [46:18 - 46:19] DeclStmt=
125*f4a2713aSLionel Sambuc// CHECK: [46:19 - 47:2] CompoundStmt=
126*f4a2713aSLionel Sambuc// CHECK: [47:2 - 47:4] TypeRef=id:0:0
127*f4a2713aSLionel Sambuc// CHECK: [47:4 - 47:6] VarDecl=c:47:12 (Definition)
128*f4a2713aSLionel Sambuc// CHECK: [47:6 - 47:10] ObjCProtocolRef=SubP:27:1
129*f4a2713aSLionel Sambuc// CHECK: [47:10 - 47:16] VarDecl=c:47:12 (Definition)
130*f4a2713aSLionel Sambuc// CHECK: [47:16 - 47:17] ObjCMessageExpr=fooC:8:3
131*f4a2713aSLionel Sambuc// CHECK: [47:17 - 47:20] ObjCClassRef=Foo:3:12
132*f4a2713aSLionel Sambuc// CHECK: [47:20 - 47:26] ObjCMessageExpr=fooC:8:3
133*f4a2713aSLionel Sambuc// CHECK: [47:26 - 47:27] DeclStmt=
134*f4a2713aSLionel Sambuc// CHECK: [47:27 - 48:2] CompoundStmt=
135*f4a2713aSLionel Sambuc// CHECK: [48:2 - 48:4] TypeRef=id:0:0
136*f4a2713aSLionel Sambuc// CHECK: [48:4 - 48:6] VarDecl=d:48:13 (Definition)
137*f4a2713aSLionel Sambuc// CHECK: [48:6 - 48:11] ObjCProtocolRef=Proto:23:1
138*f4a2713aSLionel Sambuc// CHECK: [48:11 - 48:14] VarDecl=d:48:13 (Definition)
139*f4a2713aSLionel Sambuc// CHECK: [48:14 - 48:15] DeclStmt=
140*f4a2713aSLionel Sambuc// CHECK: [48:15 - 49:2] CompoundStmt=
141*f4a2713aSLionel Sambuc// CHECK: [49:2 - 49:3] DeclRefExpr=d:48:13
142*f4a2713aSLionel Sambuc// CHECK: [49:3 - 49:6] BinaryOperator=
143*f4a2713aSLionel Sambuc// CHECK: [49:6 - 49:7] DeclRefExpr=c:47:12
144*f4a2713aSLionel Sambuc// CHECK: [49:7 - 50:2] CompoundStmt=
145*f4a2713aSLionel Sambuc// CHECK: [50:2 - 50:3] ObjCMessageExpr=pMethod:24:3
146*f4a2713aSLionel Sambuc// CHECK: [50:3 - 50:4] DeclRefExpr=d:48:13
147*f4a2713aSLionel Sambuc// CHECK: [50:4 - 50:13] ObjCMessageExpr=pMethod:24:3
148*f4a2713aSLionel Sambuc// CHECK: [50:13 - 51:2] CompoundStmt=
149*f4a2713aSLionel Sambuc// CHECK: [51:2 - 51:3] ObjCMessageExpr=catMethodWithFloat::19:9
150*f4a2713aSLionel Sambuc// CHECK: [51:3 - 51:6] DeclRefExpr=bee:45:8
151*f4a2713aSLionel Sambuc// CHECK: [51:6 - 51:26] ObjCMessageExpr=catMethodWithFloat::19:9
152*f4a2713aSLionel Sambuc// CHECK: [51:26 - 51:27] ObjCMessageExpr=floatMethod:20:1
153*f4a2713aSLionel Sambuc// CHECK: [51:27 - 51:30] DeclRefExpr=bee:45:8
154*f4a2713aSLionel Sambuc// CHECK: [51:30 - 51:43] ObjCMessageExpr=floatMethod:20:1
155*f4a2713aSLionel Sambuc// CHECK: [51:43 - 51:44] ObjCMessageExpr=catMethodWithFloat::19:9
156*f4a2713aSLionel Sambuc// CHECK: [51:44 - 52:3] CompoundStmt=
157*f4a2713aSLionel Sambuc// CHECK: [52:3 - 52:7] DeclRefExpr=main:44:5
158*f4a2713aSLionel Sambuc// CHECK: [52:7 - 52:8] CallExpr=main:44:5
159*f4a2713aSLionel Sambuc// CHECK: [52:8 - 52:16] DeclRefExpr=someEnum:41:3
160*f4a2713aSLionel Sambuc// CHECK: [52:16 - 52:18] CallExpr=main:44:5
161*f4a2713aSLionel Sambuc// CHECK: [52:18 - 52:33] CStyleCastExpr=
162*f4a2713aSLionel Sambuc// CHECK: [52:33 - 52:36] DeclRefExpr=bee:45:8
163*f4a2713aSLionel Sambuc// CHECK: [52:36 - 52:37] CallExpr=main:44:5
164*f4a2713aSLionel Sambuc// CHECK: [52:37 - 53:2] CompoundStmt=
165*f4a2713aSLionel Sambuc// CHECK: [55:9 - 55:26] macro definition=CONCAT
166*f4a2713aSLionel Sambuc// CHECK: [57:1 - 57:10] FunctionDecl=f:57:6 (Definition)
167*f4a2713aSLionel Sambuc// CHECK: [58:4 - 58:8] VarDecl=my_var:58:8 (Definition)
168*f4a2713aSLionel Sambuc// CHECK: [58:8 - 58:15] macro expansion=CONCAT:55:9
169