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 -test-annotate-tokens=%s:22:1:36:1 -target x86_64-apple-macosx10.7 %s | FileCheck %s 39 // CHECK: Identifier: "array" [24:3 - 24:8] DeclRefExpr=array:23:19 40 // CHECK: Punctuation: "[" [24:8 - 24:9] UnexposedExpr= 41 // CHECK: Literal: "3" [24:9 - 24:10] IntegerLiteral= 42 // CHECK: Punctuation: "]" [24:10 - 24:11] UnexposedExpr= 43 // CHECK: Punctuation: "=" [24:12 - 24:13] BinaryOperator= 44 // CHECK: Literal: "0" [24:14 - 24:15] IntegerLiteral= 45 // CHECK: Punctuation: ";" [24:15 - 24:16] CompoundStmt= 46 // CHECK: Identifier: "NSArray" [25:3 - 25:10] ObjCClassRef=NSArray:1:12 47 // CHECK: Punctuation: "*" [25:11 - 25:12] VarDecl=arr:25:12 (Definition) 48 // CHECK: Identifier: "arr" [25:12 - 25:15] VarDecl=arr:25:12 (Definition) 49 // CHECK: Punctuation: "=" [25:16 - 25:17] VarDecl=arr:25:12 (Definition) 50 // CHECK: Punctuation: "@" [25:18 - 25:19] UnexposedExpr= 51 // CHECK: Punctuation: "[" [25:19 - 25:20] UnexposedExpr= 52 // CHECK: Identifier: "p" [25:21 - 25:22] DeclRefExpr=p:22:28 53 // CHECK: Punctuation: "," [25:22 - 25:23] UnexposedExpr= 54 // CHECK: Identifier: "p" [25:24 - 25:25] DeclRefExpr=p:22:28 55 // CHECK: Punctuation: "]" [25:26 - 25:27] UnexposedExpr= 56 // CHECK: Punctuation: ";" [25:27 - 25:28] DeclStmt= 57 // CHECK: Keyword: "return" [26:3 - 26:9] ReturnStmt= 58 // CHECK: Identifier: "array" [26:10 - 26:15] DeclRefExpr=array:23:19 59 // CHECK: Punctuation: "[" [26:15 - 26:16] UnexposedExpr= 60 // CHECK: Identifier: "index" [26:16 - 26:21] DeclRefExpr=index:22:18 61 // CHECK: Punctuation: "]" [26:21 - 26:22] UnexposedExpr= 62 // CHECK: Punctuation: ";" [26:22 - 26:23] CompoundStmt= 63 64 // CHECK: Identifier: "oldObject" [33:3 - 33:12] DeclRefExpr=oldObject:32:17 65 // CHECK: Punctuation: "=" [33:13 - 33:14] BinaryOperator= 66 // CHECK: Identifier: "dictionary" [33:15 - 33:25] DeclRefExpr=dictionary:30:24 67 // CHECK: Punctuation: "[" [33:25 - 33:26] UnexposedExpr= 68 // CHECK: Identifier: "key" [33:26 - 33:29] DeclRefExpr=key:31:13 69 // CHECK: Punctuation: "]" [33:29 - 33:30] UnexposedExpr= 70 // CHECK: Punctuation: ";" [33:30 - 33:31] CompoundStmt= 71 // CHECK: Identifier: "dictionary" [34:3 - 34:13] DeclRefExpr=dictionary:30:24 72 // CHECK: Punctuation: "[" [34:13 - 34:14] UnexposedExpr= 73 // CHECK: Identifier: "key" [34:14 - 34:17] DeclRefExpr=key:31:13 74 // CHECK: Punctuation: "]" [34:17 - 34:18] UnexposedExpr= 75 // CHECK: Punctuation: "=" [34:19 - 34:20] BinaryOperator= 76 // CHECK: Identifier: "newObject" [34:21 - 34:30] DeclRefExpr=newObject:32:6 77 // CHECK: Punctuation: ";" [34:30 - 34:31] CompoundStmt= 78 // CHECK: Identifier: "NSDictionary" [35:3 - 35:15] ObjCClassRef=NSDictionary:11:12 79 // CHECK: Punctuation: "*" [35:16 - 35:17] VarDecl=dict:35:17 (Definition) 80 // CHECK: Identifier: "dict" [35:17 - 35:21] VarDecl=dict:35:17 (Definition) 81 // CHECK: Punctuation: "=" [35:22 - 35:23] VarDecl=dict:35:17 (Definition) 82 // CHECK: Punctuation: "@" [35:24 - 35:25] UnexposedExpr= 83 // CHECK: Punctuation: "{" [35:25 - 35:26] UnexposedExpr= 84 // CHECK: Identifier: "key" [35:27 - 35:30] DeclRefExpr=key:31:13 85 // CHECK: Punctuation: ":" [35:30 - 35:31] UnexposedExpr= 86 // CHECK: Identifier: "newObject" [35:32 - 35:41] DeclRefExpr=newObject:32:6 87 // CHECK: Punctuation: "," [35:41 - 35:42] UnexposedExpr= 88 // CHECK: Identifier: "key" [35:43 - 35:46] DeclRefExpr=key:31:13 89 // CHECK: Punctuation: ":" [35:46 - 35:47] UnexposedExpr= 90 // CHECK: Identifier: "oldObject" [35:48 - 35:57] DeclRefExpr=oldObject:32:17 91 // CHECK: Punctuation: "}" [35:58 - 35:59] UnexposedExpr= 92 // CHECK: Punctuation: ";" [35:59 - 35:60] DeclStmt= 93