blob: b39aa7bbbf004a67313c64cbcca2fd37c5317d51 [file] [log] [blame]
Nico Weberfb420782016-05-25 14:15:08 +00001// RUN: %clang_cc1 -fobjc-arc -fobjc-runtime-has-weak -triple %itanium_abi_triple -emit-llvm -fblocks -o - %s | FileCheck %s
Roger Ferrer Ibanezfd9384a2017-06-02 07:14:34 +00002// RUN: %clang_cc1 -DTEST_UNALIGNED -fms-extensions -fobjc-arc -fobjc-runtime-has-weak -triple %itanium_abi_triple -emit-llvm -fblocks -o - %s | FileCheck %s --check-prefix=UNALIGNED
John McCall31168b02011-06-15 23:02:42 +00003
David Blaikieea3e51d2015-06-29 17:29:50 +00004// CHECK-LABEL: define {{.*}}void @_Z1fPU8__strongP11objc_object(i8**)
John McCall31168b02011-06-15 23:02:42 +00005void f(__strong id *) {}
David Blaikieea3e51d2015-06-29 17:29:50 +00006// CHECK-LABEL: define {{.*}}void @_Z1fPU6__weakP11objc_object(i8**)
John McCall31168b02011-06-15 23:02:42 +00007void f(__weak id *) {}
David Blaikieea3e51d2015-06-29 17:29:50 +00008// CHECK-LABEL: define {{.*}}void @_Z1fPU15__autoreleasingP11objc_object(i8**)
John McCall31168b02011-06-15 23:02:42 +00009void f(__autoreleasing id *) {}
David Blaikieea3e51d2015-06-29 17:29:50 +000010// CHECK-LABEL: define {{.*}}void @_Z1fPP11objc_object(i8**)
John McCall31168b02011-06-15 23:02:42 +000011void f(__unsafe_unretained id *) {}
John McCall07daf722016-03-01 22:18:03 +000012// CHECK-LABEL: define {{.*}}void @_Z1fPU8__strongKP11objc_object(i8**)
John McCall31168b02011-06-15 23:02:42 +000013void f(const __strong id *) {}
John McCall07daf722016-03-01 22:18:03 +000014// CHECK-LABEL: define {{.*}}void @_Z1fPU6__weakKP11objc_object(i8**)
John McCall31168b02011-06-15 23:02:42 +000015void f(const __weak id *) {}
John McCall07daf722016-03-01 22:18:03 +000016// CHECK-LABEL: define {{.*}}void @_Z1fPU15__autoreleasingKP11objc_object(i8**)
John McCall31168b02011-06-15 23:02:42 +000017void f(const __autoreleasing id *) {}
David Blaikieea3e51d2015-06-29 17:29:50 +000018// CHECK-LABEL: define {{.*}}void @_Z1fPKP11objc_object(i8**)
John McCall31168b02011-06-15 23:02:42 +000019void f(const __unsafe_unretained id *) {}
John McCall07daf722016-03-01 22:18:03 +000020// CHECK-LABEL: define {{.*}}void @_Z1fPFU19ns_returns_retainedP11objc_objectvE
21void f(__attribute__((ns_returns_retained)) id (*fn)()) {}
Nico Weberfb420782016-05-25 14:15:08 +000022// CHECK-LABEL: define {{.*}}void @_Z1fP11objc_object
23void f(__attribute__((ns_consumed)) id) {}
John McCall07daf722016-03-01 22:18:03 +000024// CHECK-LABEL: define {{.*}}void @_Z1fPFP11objc_objectU11ns_consumedS0_S0_E
25void f(id (*fn)(__attribute__((ns_consumed)) id, id)) {}
26// CHECK-LABEL: define {{.*}}void @_Z1fPFP11objc_objectS0_U11ns_consumedS0_E
27void f(__strong id (*fn)(id, __attribute__((ns_consumed)) id)) {}
Nico Weberfb420782016-05-25 14:15:08 +000028// CHECK-LABEL: define {{.*}}void @_Z1fU13block_pointerFvU11ns_consumedP11objc_objectE
29void f(void (^)(__attribute__((ns_consumed)) id)) {}
John McCall31168b02011-06-15 23:02:42 +000030
31template<unsigned N> struct unsigned_c { };
32
David Blaikieea3e51d2015-06-29 17:29:50 +000033// CHECK-LABEL: define weak_odr {{.*}}void @_Z1gIKvEvP10unsigned_cIXplszv1U8__bridgecvPT_v1U8__bridgecvP11objc_objectcvS3_Li0ELi1EEE
John McCall31168b02011-06-15 23:02:42 +000034template<typename T>void g(unsigned_c<sizeof((__bridge T*)(__bridge id)(T*)0) + 1>*) {}
35template void g<const void>(unsigned_c<sizeof(id) + 1> *);
Roger Ferrer Ibanezfd9384a2017-06-02 07:14:34 +000036
37#if TEST_UNALIGNED
38// UNALIGNED-LABEL: define {{.*}}void @_Z1gPU6__weakU11__unalignedP11objc_object(i8**)
39void g(__weak __unaligned id *) {}
40// UNALIGNED-LABEL: define {{.*}}void @_Z1gPU11__unalignedU8__strongP11objc_object(i8**)
41void g(__strong __unaligned id *) {}
42// UNALIGNED-LABEL: define {{.*}}void @_Z1gPU11__unalignedU15__autoreleasingP11objc_object(i8**)
43void g(__autoreleasing __unaligned id *) {}
44#endif // TEST_UNALIGNED