Ted Kremenek | b3f7542 | 2012-03-06 20:06:06 +0000 | [diff] [blame] | 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 | int idx; |
| 23 | id p; |
| 24 | |
| 25 | id testArray() { |
| 26 | NSMutableArray *array; |
| 27 | array[idx] = p; |
| 28 | NSArray *arr = @[ p, p ]; |
| 29 | return array[idx]; |
| 30 | } |
| 31 | |
| 32 | NSString *key; |
| 33 | id newObject, oldObject; |
| 34 | |
| 35 | void testDict() { |
| 36 | NSMutableDictionary *dictionary; |
| 37 | oldObject = dictionary[key]; |
| 38 | dictionary[key] = newObject; |
| 39 | NSDictionary *dict = @{ key: newObject, key: oldObject }; |
| 40 | } |
| 41 | |
| 42 | // RUN: c-index-test -index-file -target x86_64-apple-macosx10.7 %s | FileCheck %s |
| 43 | |
| 44 | // CHECK: [indexEntityReference]: kind: variable | name: idx | USR: c:@idx | lang: C | cursor: DeclRefExpr=idx:22:5 | loc: 27:9 |
Fangrui Song | 8669315 | 2018-02-12 17:42:09 +0000 | [diff] [blame] | 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 |
Ted Kremenek | b3f7542 | 2012-03-06 20:06:06 +0000 | [diff] [blame] | 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 |
| 54 | |
| 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 |