Debian Codegraph @

clang/test/Rewriter/objc-modern-container-subscript.mm

raw
1 // RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
2 // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
3
4 typedef unsigned long size_t;
5
6 void *sel_registerName(const char *);
7
8 @protocol P @end
9
10 @interface NSMutableArray
11 #if __has_feature(objc_subscripting)
12 - (id)objectAtIndexedSubscript:(size_t)index;
13 - (void)setObject:(id)object atIndexedSubscript:(size_t)index;
14 #endif
15 @end
16
17 #if __has_feature(objc_subscripting)
18 @interface XNSMutableArray
19 - (id)objectAtIndexedSubscript:(size_t)index;
20 - (void)setObject:(id)object atIndexedSubscript:(size_t)index;
21 #endif
22 @end
23
24 @interface NSMutableDictionary
25 - (id)objectForKeyedSubscript:(id)key;
26 - (void)setObject:(id)object forKeyedSubscript:(id)key;
27 @end
28
29 @class NSString;
30
31 int main() {
32 NSMutableArray<P> * array;
33 id oldObject = array[10];
34
35 array[10] = oldObject;
36
37 id unknown_array;
38 oldObject = unknown_array[1];
39
40 unknown_array[1] = oldObject;
41
42 NSMutableDictionary *dictionary;
43 NSString *key;
44 id newObject;
45 oldObject = dictionary[key];
46 dictionary[key] = newObject; // replace oldObject with newObject
47 }
48