[Reland][Runtimes] Merge 'compile_commands.json' files from runtimes build (#116303)
[llvm-project.git] / clang / test / Rewriter / objc-modern-container-subscript.mm
blob7c417eb9a6ef9074954c54ffc7d09fd6dfa4fa1a
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
4 typedef unsigned long size_t;
6 void *sel_registerName(const char *);
8 @protocol P @end
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
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
24 @interface NSMutableDictionary
25 - (id)objectForKeyedSubscript:(id)key;
26 - (void)setObject:(id)object forKeyedSubscript:(id)key;
27 @end
29 @class NSString;
31 int main() {
32   NSMutableArray<P> * array;
33   id oldObject = array[10];
35   array[10] = oldObject;
37   id unknown_array;
38   oldObject = unknown_array[1];
40   unknown_array[1] = oldObject;
42   NSMutableDictionary *dictionary;
43   NSString *key;
44   id newObject;
45   oldObject = dictionary[key];
46   dictionary[key] = newObject;  // replace oldObject with newObject