xref: /minix3/external/bsd/llvm/dist/clang/test/Index/get-cursor.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// Test is line- and column-sensitive. Run lines are below.
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambuc@interface rdar9771715
4*f4a2713aSLionel Sambuc@property (readonly) int foo1;
5*f4a2713aSLionel Sambuc@property (readwrite) int foo2;
6*f4a2713aSLionel Sambuc@end
7*f4a2713aSLionel Sambuc
8*f4a2713aSLionel Sambuc@class Foo;
9*f4a2713aSLionel Sambuc
10*f4a2713aSLionel Sambuc@interface rdar9535717 {
11*f4a2713aSLionel Sambuc  __weak Foo *foo;
12*f4a2713aSLionel Sambuc}
13*f4a2713aSLionel Sambuc@end
14*f4a2713aSLionel Sambuc
15*f4a2713aSLionel Sambuc@interface Test1 {
16*f4a2713aSLionel Sambuc  id _name;
17*f4a2713aSLionel Sambuc}
18*f4a2713aSLionel Sambuc@end
19*f4a2713aSLionel Sambuc@interface Test1 ()
20*f4a2713aSLionel Sambuc- (id)name;
21*f4a2713aSLionel Sambuc@end
22*f4a2713aSLionel Sambuc@interface Test1 ()
23*f4a2713aSLionel Sambuc@property (copy) id name;
24*f4a2713aSLionel Sambuc@end
25*f4a2713aSLionel Sambuc@implementation Test1
26*f4a2713aSLionel Sambuc@synthesize name = _name;
27*f4a2713aSLionel Sambuc@end
28*f4a2713aSLionel Sambuc
29*f4a2713aSLionel Sambuc@interface rdar10902015
30*f4a2713aSLionel Sambuc@end
31*f4a2713aSLionel Sambuc
32*f4a2713aSLionel Sambuc@implementation rdar10902015
33*f4a2713aSLionel Sambuc
34*f4a2713aSLionel Sambucstruct S { int x; };
35*f4a2713aSLionel Sambuc
36*f4a2713aSLionel Sambuc-(void)mm:(struct S*)s {
37*f4a2713aSLionel Sambuc  rdar10902015 *i = 0;
38*f4a2713aSLionel Sambuc  s->x = 0;
39*f4a2713aSLionel Sambuc  Test1 *test1;
40*f4a2713aSLionel Sambuc  test1.name = 0;
41*f4a2713aSLionel Sambuc}
42*f4a2713aSLionel Sambuc@end
43*f4a2713aSLionel Sambuc
44*f4a2713aSLionel Sambuc@interface Test2
45*f4a2713aSLionel Sambuc-(int)implicitProp;
46*f4a2713aSLionel Sambuc-(void)setImplicitProp:(int)x;
47*f4a2713aSLionel Sambuc@end
48*f4a2713aSLionel Sambuc
49*f4a2713aSLionel Sambucvoid foo1(Test2 *test2) {
50*f4a2713aSLionel Sambuc  int x = test2.implicitProp;
51*f4a2713aSLionel Sambuc  test2.implicitProp = x;
52*f4a2713aSLionel Sambuc  ++test2.implicitProp;
53*f4a2713aSLionel Sambuc}
54*f4a2713aSLionel Sambuc
55*f4a2713aSLionel Sambuc@interface Test3
56*f4a2713aSLionel Sambuc-(void)setFoo:(int)x withBar:(int)y;
57*f4a2713aSLionel Sambuc@end
58*f4a2713aSLionel Sambuc
59*f4a2713aSLionel Sambucvoid foo3(Test3 *test3) {
60*f4a2713aSLionel Sambuc  [test3 setFoo:2 withBar:4];
61*f4a2713aSLionel Sambuc}
62*f4a2713aSLionel Sambuc
63*f4a2713aSLionel Sambuc@interface Test4
64*f4a2713aSLionel Sambuc@end
65*f4a2713aSLionel Sambuc@interface Test4(Dido)
66*f4a2713aSLionel Sambuc@end
67*f4a2713aSLionel Sambuc@implementation Test4(Dido)
68*f4a2713aSLionel Sambuc@end
69*f4a2713aSLionel Sambuc
70*f4a2713aSLionel Sambuc@class Forw1, Forw2, Forw3;
71*f4a2713aSLionel Sambuc
72*f4a2713aSLionel Sambuc@interface Test5 {
73*f4a2713aSLionel Sambuc  id prop1;
74*f4a2713aSLionel Sambuc  id prop2;
75*f4a2713aSLionel Sambuc}
76*f4a2713aSLionel Sambuc@property (assign) id prop1;
77*f4a2713aSLionel Sambuc@property (assign) id prop2;
78*f4a2713aSLionel Sambuc@property (assign) id prop3;
79*f4a2713aSLionel Sambuc@property (assign) id prop4;
80*f4a2713aSLionel Sambuc@end
81*f4a2713aSLionel Sambuc
82*f4a2713aSLionel Sambuc@implementation Test5
83*f4a2713aSLionel Sambuc@synthesize prop1, prop2;
84*f4a2713aSLionel Sambuc@dynamic prop3, prop4;
85*f4a2713aSLionel Sambuc
86*f4a2713aSLionel Sambuc-(id)meth1 {
87*f4a2713aSLionel Sambuc  return 0;
88*f4a2713aSLionel Sambuc}
89*f4a2713aSLionel Sambuc-(id)meth2{
90*f4a2713aSLionel Sambuc  return 0;
91*f4a2713aSLionel Sambuc}
92*f4a2713aSLionel Sambuc@end
93*f4a2713aSLionel Sambuc
94*f4a2713aSLionel Sambuc@interface Test6
95*f4a2713aSLionel Sambuc@property (assign) id prop1;
96*f4a2713aSLionel Sambuc@end
97*f4a2713aSLionel Sambuc
98*f4a2713aSLionel Sambuc@implementation Test6
99*f4a2713aSLionel Sambuc@synthesize prop1 = _prop1;
100*f4a2713aSLionel Sambuc@end
101*f4a2713aSLionel Sambuc
102*f4a2713aSLionel Sambuc@protocol TestProt
103*f4a2713aSLionel Sambuc-(void)protMeth1;
104*f4a2713aSLionel Sambuc@property (retain) id propProp1;
105*f4a2713aSLionel Sambuc
106*f4a2713aSLionel Sambuc@optional
107*f4a2713aSLionel Sambuc-(void)protMeth2;
108*f4a2713aSLionel Sambuc@property (retain) id propProp2;
109*f4a2713aSLionel Sambuc
110*f4a2713aSLionel Sambuc@required
111*f4a2713aSLionel Sambuc-(void)protMeth3;
112*f4a2713aSLionel Sambuc@property (retain) id propProp3;
113*f4a2713aSLionel Sambuc@end
114*f4a2713aSLionel Sambuc
115*f4a2713aSLionel Sambuc
116*f4a2713aSLionel Sambuc// RUN: c-index-test -cursor-at=%s:4:28 -cursor-at=%s:5:28 %s | FileCheck -check-prefix=CHECK-PROP %s
117*f4a2713aSLionel Sambuc// CHECK-PROP: ObjCPropertyDecl=foo1:4:26
118*f4a2713aSLionel Sambuc// CHECK-PROP: ObjCPropertyDecl=foo2:5:27
119*f4a2713aSLionel Sambuc
120*f4a2713aSLionel Sambuc// RUN: c-index-test -cursor-at=%s:11:11 %s -target x86_64-apple-macosx10.7.0 | FileCheck -check-prefix=CHECK-WITH-WEAK %s
121*f4a2713aSLionel Sambuc// CHECK-WITH-WEAK: ObjCClassRef=Foo:8:8
122*f4a2713aSLionel Sambuc
123*f4a2713aSLionel Sambuc// RUN: c-index-test -cursor-at=%s:20:10 %s | FileCheck -check-prefix=CHECK-METHOD %s
124*f4a2713aSLionel Sambuc// CHECK-METHOD: 20:7 ObjCInstanceMethodDecl=name:20:7 Extent=[20:1 - 20:12]
125*f4a2713aSLionel Sambuc
126*f4a2713aSLionel Sambuc// RUN: c-index-test -cursor-at=%s:37:17 %s | FileCheck -check-prefix=CHECK-IN-IMPL %s
127*f4a2713aSLionel Sambuc// CHECK-IN-IMPL: VarDecl=i:37:17
128*f4a2713aSLionel Sambuc
129*f4a2713aSLionel Sambuc// RUN: c-index-test -cursor-at=%s:38:6 -cursor-at=%s:40:11 \
130*f4a2713aSLionel Sambuc// RUN:   -cursor-at=%s:50:20 -cursor-at=%s:51:15 -cursor-at=%s:52:20 %s | FileCheck -check-prefix=CHECK-MEMBERREF %s
131*f4a2713aSLionel Sambuc// CHECK-MEMBERREF: 38:6 MemberRefExpr=x:34:16 SingleRefName=[38:6 - 38:7] RefName=[38:6 - 38:7] Extent=[38:3 - 38:7]
132*f4a2713aSLionel Sambuc// CHECK-MEMBERREF: 40:9 MemberRefExpr=name:23:21 Extent=[40:3 - 40:13] Spelling=name ([40:9 - 40:13])
133*f4a2713aSLionel Sambuc// CHECK-MEMBERREF: 50:17 MemberRefExpr=implicitProp:45:7 Extent=[50:11 - 50:29] Spelling=implicitProp ([50:17 - 50:29])
134*f4a2713aSLionel Sambuc// CHECK-MEMBERREF: 51:9 MemberRefExpr=setImplicitProp::46:8 Extent=[51:3 - 51:21] Spelling=setImplicitProp: ([51:9 - 51:21])
135*f4a2713aSLionel Sambuc// CHECK-MEMBERREF: 52:11 MemberRefExpr=setImplicitProp::46:8 Extent=[52:5 - 52:23] Spelling=setImplicitProp: ([52:11 - 52:23])
136*f4a2713aSLionel Sambuc
137*f4a2713aSLionel Sambuc// RUN: c-index-test -cursor-at=%s:56:24 -cursor-at=%s:60:14 \
138*f4a2713aSLionel Sambuc// RUN:   -cursor-at=%s:65:20 -cursor-at=%s:67:25 \
139*f4a2713aSLionel Sambuc// RUN:   -cursor-at=%s:70:10 -cursor-at=%s:70:16 -cursor-at=%s:70:25 \
140*f4a2713aSLionel Sambuc// RUN:   %s | FileCheck -check-prefix=CHECK-SPELLRANGE %s
141*f4a2713aSLionel Sambuc// CHECK-SPELLRANGE: 56:8 ObjCInstanceMethodDecl=setFoo:withBar::56:8 Extent=[56:1 - 56:37] Spelling=setFoo:withBar: ([56:8 - 56:14][56:22 - 56:29]) Selector index=1
142*f4a2713aSLionel Sambuc// CHECK-SPELLRANGE: 60:3 ObjCMessageExpr=setFoo:withBar::56:8 Extent=[60:3 - 60:29] Spelling=setFoo:withBar: ([60:10 - 60:16][60:19 - 60:26]) Selector index=0
143*f4a2713aSLionel Sambuc// CHECK-SPELLRANGE: 65:12 ObjCCategoryDecl=Dido:65:12 Extent=[65:1 - 66:5] Spelling=Dido ([65:18 - 65:22])
144*f4a2713aSLionel Sambuc// CHECK-SPELLRANGE: 67:17 ObjCCategoryImplDecl=Dido:67:17 (Definition) Extent=[67:1 - 68:2] Spelling=Dido ([67:23 - 67:27])
145*f4a2713aSLionel Sambuc
146*f4a2713aSLionel Sambuc// CHECK-SPELLRANGE: 70:8 ObjCClassRef=Forw1:70:8 Extent=[70:8 - 70:13] Spelling=Forw1 ([70:8 - 70:13])
147*f4a2713aSLionel Sambuc// CHECK-SPELLRANGE: 70:15 ObjCClassRef=Forw2:70:15 Extent=[70:15 - 70:20] Spelling=Forw2 ([70:15 - 70:20])
148*f4a2713aSLionel Sambuc// CHECK-SPELLRANGE: 70:22 ObjCClassRef=Forw3:70:22 Extent=[70:22 - 70:27] Spelling=Forw3 ([70:22 - 70:27])
149*f4a2713aSLionel Sambuc
150*f4a2713aSLionel Sambuc// RUN: c-index-test -cursor-at=%s:83:15 -cursor-at=%s:83:21 \
151*f4a2713aSLionel Sambuc// RUN:              -cursor-at=%s:84:12 -cursor-at=%s:84:20 \
152*f4a2713aSLionel Sambuc// RUN:              -cursor-at=%s:99:14 -cursor-at=%s:99:23 %s | FileCheck -check-prefix=CHECK-MULTISYNTH %s
153*f4a2713aSLionel Sambuc// CHECK-MULTISYNTH: 83:13 ObjCSynthesizeDecl=prop1:76:23 (Definition) Extent=[83:1 - 83:18] Spelling=prop1 ([83:13 - 83:18])
154*f4a2713aSLionel Sambuc// CHECK-MULTISYNTH: 83:20 ObjCSynthesizeDecl=prop2:77:23 (Definition) Extent=[83:1 - 83:25] Spelling=prop2 ([83:20 - 83:25])
155*f4a2713aSLionel Sambuc// CHECK-MULTISYNTH: 84:10 ObjCDynamicDecl=prop3:78:23 (Definition) Extent=[84:1 - 84:15] Spelling=prop3 ([84:10 - 84:15])
156*f4a2713aSLionel Sambuc// CHECK-MULTISYNTH: 84:17 ObjCDynamicDecl=prop4:79:23 (Definition) Extent=[84:1 - 84:22] Spelling=prop4 ([84:17 - 84:22])
157*f4a2713aSLionel Sambuc// CHECK-MULTISYNTH: 99:13 ObjCSynthesizeDecl=prop1:95:23 (Definition) Extent=[99:1 - 99:27] Spelling=prop1 ([99:13 - 99:18])
158*f4a2713aSLionel Sambuc// CHECK-MULTISYNTH: 99:21 MemberRef=_prop1:99:21 Extent=[99:21 - 99:27] Spelling=_prop1 ([99:21 - 99:27])
159*f4a2713aSLionel Sambuc
160*f4a2713aSLionel Sambuc// RUN: c-index-test -cursor-at=%s:86:7 -cursor-at=%s:89:7 %s | FileCheck -check-prefix=CHECK-SELECTORLOC %s
161*f4a2713aSLionel Sambuc// CHECK-SELECTORLOC: 86:6 ObjCInstanceMethodDecl=meth1:86:6 (Definition) Extent=[86:1 - 88:2] Spelling=meth1 ([86:6 - 86:11]) Selector index=0
162*f4a2713aSLionel Sambuc// CHECK-SELECTORLOC: 89:6 ObjCInstanceMethodDecl=meth2:89:6 (Definition) Extent=[89:1 - 91:2] Spelling=meth2 ([89:6 - 89:11]) Selector index=0
163*f4a2713aSLionel Sambuc
164*f4a2713aSLionel Sambuc// RUN: c-index-test -cursor-at=%s:103:10 -cursor-at=%s:104:10 \
165*f4a2713aSLionel Sambuc// RUN:              -cursor-at=%s:107:10 -cursor-at=%s:108:10 \
166*f4a2713aSLionel Sambuc// RUN:              -cursor-at=%s:111:10 -cursor-at=%s:112:10 %s | FileCheck -check-prefix=CHECK-OBJCOPTIONAL %s
167*f4a2713aSLionel Sambuc// CHECK-OBJCOPTIONAL: 103:8 ObjCInstanceMethodDecl=protMeth1:103:8 Extent=[103:1 - 103:18]
168*f4a2713aSLionel Sambuc// CHECK-OBJCOPTIONAL: 104:23 ObjCPropertyDecl=propProp1:104:23 [retain,] Extent=[104:1 - 104:32]
169*f4a2713aSLionel Sambuc// CHECK-OBJCOPTIONAL: 107:8 ObjCInstanceMethodDecl=protMeth2:107:8 (@optional) Extent=[107:1 - 107:18]
170*f4a2713aSLionel Sambuc// CHECK-OBJCOPTIONAL: 108:23 ObjCPropertyDecl=propProp2:108:23 (@optional) [retain,] Extent=[108:1 - 108:32]
171*f4a2713aSLionel Sambuc// CHECK-OBJCOPTIONAL: 111:8 ObjCInstanceMethodDecl=protMeth3:111:8 Extent=[111:1 - 111:18]
172*f4a2713aSLionel Sambuc// CHECK-OBJCOPTIONAL: 112:23 ObjCPropertyDecl=propProp3:112:23 [retain,] Extent=[112:1 - 112:32]
173