[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Index / index-subscripting-literals.m
blob08b936a5ea8e2688d8426e5f370390560c3db2db
1 @interface NSArray
2 - (id)objectAtIndexedSubscript:(int)index;
3 + (id)arrayWithObjects:(id *)objects count:(unsigned)count;
4 @end
6 @interface NSMutableArray : NSArray
7 - (id)objectAtIndexedSubscript:(int)index;
8 - (void)setObject:(id)object atIndexedSubscript:(int)index;
9 @end
11 @interface NSDictionary
12 - (id)objectForKeyedSubscript:(id)key;
13 + (id)dictionaryWithObjects:(id *)objects forKeys:(id *)keys count:(unsigned)count;
14 @end
16 @interface NSMutableDictionary : NSDictionary
17 - (void)setObject:(id)object forKeyedSubscript:(id)key;
18 @end
20 @class NSString;
22 int idx;
23 id p;
25 id testArray() {
26   NSMutableArray *array;
27   array[idx] = p;
28   NSArray *arr = @[ p, p ];
29   return array[idx];
32 NSString *key;
33 id newObject, oldObject;
35 void testDict() {
36   NSMutableDictionary *dictionary;
37   oldObject = dictionary[key];
38   dictionary[key] = newObject;
39   NSDictionary *dict = @{ key: newObject, key: oldObject };
42 // RUN: c-index-test -index-file -target x86_64-apple-macosx10.7 %s | FileCheck %s
44 // CHECK:      [indexEntityReference]: kind: variable | name: idx | USR: c:@idx | lang: C | cursor: DeclRefExpr=idx:22:5 | loc: 27:9
45 // CHECK-NEXT: [indexEntityReference]: kind: variable | name: p | USR: c:@p | lang: C | cursor: DeclRefExpr=p:23:4 | loc: 27:16 | <parent>:: kind: function | name: testArray | USR: c:@F@testArray | lang: C | container: [testArray:25:4] | refkind: direct | role: ref
46 // CHECK-NEXT: [indexEntityReference]: kind: objc-instance-method | name: setObject:atIndexedSubscript:
47 // CHECK-NEXT: [indexEntityReference]: kind: objc-class | name: NSArray
48 // CHECK-NEXT: [indexEntityReference]: kind: objc-class-method | name: arrayWithObjects:count: 
49 // CHECK-NEXT: [indexEntityReference]: kind: variable | name: p | USR: c:@p | lang: C | cursor: DeclRefExpr=p:23:4 | loc: 28:21
50 // CHECK-NEXT: [indexEntityReference]: kind: variable | name: p | USR: c:@p | lang: C | cursor: DeclRefExpr=p:23:4 | loc: 28:24
51 // CHECK-NEXT: [indexEntityReference]: kind: variable | name: idx | USR: c:@idx | lang: C | cursor: DeclRefExpr=idx:22:5 | loc: 29:16
52 // CHECK-NEXT: [indexEntityReference]: kind: objc-instance-method | name: objectAtIndexedSubscript:
53 // CHECK-NEXT: [indexDeclaration]: kind: variable | name: key
55 // CHECK:      [indexEntityReference]: kind: variable | name: oldObject
56 // CHECK-NEXT: [indexEntityReference]: kind: variable | name: key | USR: c:@key | lang: C | cursor: DeclRefExpr=key:32:11 | loc: 37:26
57 // CHECK-NEXT: [indexEntityReference]: kind: objc-instance-method | name: objectForKeyedSubscript:
58 // CHECK-NEXT: [indexEntityReference]: kind: variable | name: key | USR: c:@key | lang: C | cursor: DeclRefExpr=key:32:11 | loc: 38:14
59 // CHECK-NEXT: [indexEntityReference]: kind: variable | name: newObject | USR: c:@newObject | lang: C | cursor: DeclRefExpr=newObject:33:4 | loc: 38:21
60 // CHECK-NEXT: [indexEntityReference]: kind: objc-instance-method | name: setObject:forKeyedSubscript:
61 // CHECK-NEXT: [indexEntityReference]: kind: objc-class | name: NSDictionary
62 // CHECK-NEXT: [indexEntityReference]: kind: objc-class-method | name: dictionaryWithObjects:forKeys:count: 
63 // CHECK-NEXT: [indexEntityReference]: kind: variable | name: key | USR: c:@key | lang: C | cursor: DeclRefExpr=key:32:11 | loc: 39:27
64 // CHECK-NEXT: [indexEntityReference]: kind: variable | name: newObject | USR: c:@newObject | lang: C | cursor: DeclRefExpr=newObject:33:4 | loc: 39:32
65 // CHECK-NEXT: [indexEntityReference]: kind: variable | name: key | USR: c:@key | lang: C | cursor: DeclRefExpr=key:32:11 | loc: 39:43
66 // CHECK-NEXT: [indexEntityReference]: kind: variable | name: oldObject | USR: c:@oldObject | lang: C | cursor: DeclRefExpr=oldObject:33:15 | loc: 39:48