58 lines · plain
1// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -o - %s | FileCheck %s2 3typedef unsigned int size_t;4@protocol P @end5 6@interface NSMutableArray7- (id)objectAtIndexedSubscript:(size_t)index;8- (void)setObject:(id)object atIndexedSubscript:(size_t)index;9@end10 11struct S {12 operator unsigned int ();13 operator id ();14};15 16@interface NSMutableDictionary17- (id)objectForKeyedSubscript:(id)key;18- (void)setObject:(id)object forKeyedSubscript:(id)key;19@end20 21int main() {22 NSMutableArray<P> * array;23 S s;24 id oldObject = array[(int)s];25 26 NSMutableDictionary<P> *dict;27 dict[(id)s] = oldObject;28 oldObject = dict[(id)s];29 30}31 32template <class T> void test2(NSMutableArray *a) {33 a[10] = 0;34}35template void test2<int>(NSMutableArray*);36// CHECK-LABEL: define weak_odr void @_Z5test2IiEvP14NSMutableArray37// CHECK: @objc_msgSend 38// CHECK: ret void39 40 41template <class T> void test3(NSMutableArray *a) {42 a[sizeof(T)] = 0;43}44 45template void test3<int>(NSMutableArray*);46// CHECK-LABEL: define weak_odr void @_Z5test3IiEvP14NSMutableArray47// CHECK: @objc_msgSend48// CHECK: ret void49 50// CHECK-LABEL: define{{.*}} void @_Z11static_dataP14NSMutableArray51void static_data(NSMutableArray *array) {52 // CHECK: call i32 @__cxa_guard_acquire53 // CHECK: call noundef ptr @objc_msgSend54 // CHECK: call void @__cxa_guard_release55 static id x = array[4];56 // CHECK: ret void57}58