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