| 1 |
// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -o - %s | FileCheck %s |
| 2 |
|
| 3 |
typedef unsigned int size_t; |
| 4 |
@protocol P @end |
| 5 |
|
| 6 |
@interface NSMutableArray |
| 7 |
- (id)objectAtIndexedSubscript:(size_t)index; |
| 8 |
- (void)setObject:(id)object atIndexedSubscript:(size_t)index; |
| 9 |
@end |
| 10 |
|
| 11 |
struct S { |
| 12 |
operator unsigned int (); |
| 13 |
operator id (); |
| 14 |
}; |
| 15 |
|
| 16 |
@interface NSMutableDictionary |
| 17 |
- (id)objectForKeyedSubscript:(id)key; |
| 18 |
- (void)setObject:(id)object forKeyedSubscript:(id)key; |
| 19 |
@end |
| 20 |
|
| 21 |
int 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 |
|
| 32 |
template <class T> void test2(NSMutableArray *a) { |
| 33 |
a[10] = 0; |
| 34 |
} |
| 35 |
template void test2<int>(NSMutableArray*); |
| 36 |
// CHECK-LABEL: define weak_odr void @_Z5test2IiEvP14NSMutableArray |
| 37 |
// CHECK: @objc_msgSend |
| 38 |
// CHECK: ret void |
| 39 |
|
| 40 |
|
| 41 |
template <class T> void test3(NSMutableArray *a) { |
| 42 |
a[sizeof(T)] = 0; |
| 43 |
} |
| 44 |
|
| 45 |
template void test3<int>(NSMutableArray*); |
| 46 |
// CHECK-LABEL: define weak_odr void @_Z5test3IiEvP14NSMutableArray |
| 47 |
// CHECK: @objc_msgSend |
| 48 |
// CHECK: ret void |
| 49 |
|
| 50 |
// CHECK-LABEL: define{{.*}} void @_Z11static_dataP14NSMutableArray |
| 51 |
void static_data(NSMutableArray *array) { |
| 52 |
// CHECK: call i32 @__cxa_guard_acquire |
| 53 |
// CHECK: call noundef ptr @objc_msgSend |
| 54 |
// CHECK: call void @__cxa_guard_release |
| 55 |
static id x = array[4]; |
| 56 |
// CHECK: ret void |
| 57 |
} |