xref: /minix3/external/bsd/llvm/dist/clang/test/Index/file-refs-subscripting.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc@interface NSArray
2*f4a2713aSLionel Sambuc- (id)objectAtIndexedSubscript:(int)index;
3*f4a2713aSLionel Sambuc+ (id)arrayWithObjects:(id *)objects count:(unsigned)count;
4*f4a2713aSLionel Sambuc@end
5*f4a2713aSLionel Sambuc
6*f4a2713aSLionel Sambuc@interface NSMutableArray : NSArray
7*f4a2713aSLionel Sambuc- (id)objectAtIndexedSubscript:(int)index;
8*f4a2713aSLionel Sambuc- (void)setObject:(id)object atIndexedSubscript:(int)index;
9*f4a2713aSLionel Sambuc@end
10*f4a2713aSLionel Sambuc
11*f4a2713aSLionel Sambuc@interface NSDictionary
12*f4a2713aSLionel Sambuc- (id)objectForKeyedSubscript:(id)key;
13*f4a2713aSLionel Sambuc+ (id)dictionaryWithObjects:(id *)objects forKeys:(id *)keys count:(unsigned)count;
14*f4a2713aSLionel Sambuc@end
15*f4a2713aSLionel Sambuc
16*f4a2713aSLionel Sambuc@interface NSMutableDictionary : NSDictionary
17*f4a2713aSLionel Sambuc- (void)setObject:(id)object forKeyedSubscript:(id)key;
18*f4a2713aSLionel Sambuc@end
19*f4a2713aSLionel Sambuc
20*f4a2713aSLionel Sambuc@class NSString;
21*f4a2713aSLionel Sambuc
22*f4a2713aSLionel Sambucid testArray(int index, id p) {
23*f4a2713aSLionel Sambuc  NSMutableArray *array;
24*f4a2713aSLionel Sambuc  array[3] = 0;
25*f4a2713aSLionel Sambuc  NSArray *arr = @[ p, p ];
26*f4a2713aSLionel Sambuc  return array[index];
27*f4a2713aSLionel Sambuc}
28*f4a2713aSLionel Sambuc
29*f4a2713aSLionel Sambucvoid testDict() {
30*f4a2713aSLionel Sambuc  NSMutableDictionary *dictionary;
31*f4a2713aSLionel Sambuc  NSString *key;
32*f4a2713aSLionel Sambuc  id newObject, oldObject;
33*f4a2713aSLionel Sambuc  oldObject = dictionary[key];
34*f4a2713aSLionel Sambuc  dictionary[key] = newObject;
35*f4a2713aSLionel Sambuc  NSDictionary *dict = @{ key: newObject, key: oldObject };
36*f4a2713aSLionel Sambuc}
37*f4a2713aSLionel Sambuc
38*f4a2713aSLionel Sambuc// RUN: c-index-test \
39*f4a2713aSLionel Sambuc
40*f4a2713aSLionel Sambuc// RUN:  -file-refs-at=%s:22:21 \
41*f4a2713aSLionel Sambuc// CHECK:      ParmDecl=index:22:18
42*f4a2713aSLionel Sambuc// CHECK-NEXT: ParmDecl=index:22:18 (Definition) =[22:18 - 22:23]
43*f4a2713aSLionel Sambuc// CHECK-NEXT: DeclRefExpr=index:22:18 =[26:16 - 26:21]
44*f4a2713aSLionel Sambuc
45*f4a2713aSLionel Sambuc// RUN:  -file-refs-at=%s:22:28 \
46*f4a2713aSLionel Sambuc// CHECK-NEXT: ParmDecl=p:22:28
47*f4a2713aSLionel Sambuc// CHECK-NEXT: ParmDecl=p:22:28 (Definition) =[22:28 - 22:29]
48*f4a2713aSLionel Sambuc// CHECK-NEXT: DeclRefExpr=p:22:28 =[25:21 - 25:22]
49*f4a2713aSLionel Sambuc// CHECK-NEXT: DeclRefExpr=p:22:28 =[25:24 - 25:25]
50*f4a2713aSLionel Sambuc
51*f4a2713aSLionel Sambuc// RUN:  -file-refs-at=%s:34:16 \
52*f4a2713aSLionel Sambuc// CHECK-NEXT: DeclRefExpr=key:31:13
53*f4a2713aSLionel Sambuc// CHECK-NEXT: VarDecl=key:31:13 (Definition) =[31:13 - 31:16]
54*f4a2713aSLionel Sambuc// CHECK-NEXT: DeclRefExpr=key:31:13 =[33:26 - 33:29]
55*f4a2713aSLionel Sambuc// CHECK-NEXT: DeclRefExpr=key:31:13 =[34:14 - 34:17]
56*f4a2713aSLionel Sambuc// CHECK-NEXT: DeclRefExpr=key:31:13 =[35:27 - 35:30]
57*f4a2713aSLionel Sambuc// CHECK-NEXT: DeclRefExpr=key:31:13 =[35:43 - 35:46]
58*f4a2713aSLionel Sambuc
59*f4a2713aSLionel Sambuc// RUN:  -file-refs-at=%s:35:35 \
60*f4a2713aSLionel Sambuc// CHECK-NEXT: DeclRefExpr=newObject:32:6
61*f4a2713aSLionel Sambuc// CHECK-NEXT: VarDecl=newObject:32:6 (Definition) =[32:6 - 32:15]
62*f4a2713aSLionel Sambuc// CHECK-NEXT: DeclRefExpr=newObject:32:6 =[34:21 - 34:30]
63*f4a2713aSLionel Sambuc// CHECK-NEXT: DeclRefExpr=newObject:32:6 =[35:32 - 35:41]
64*f4a2713aSLionel Sambuc
65*f4a2713aSLionel Sambuc// RUN:   -target x86_64-apple-macosx10.7 %s | FileCheck %s
66