2019-05-11 01:52:26 +08:00
|
|
|
// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-macosx10.13.0 -o - | FileCheck %s --check-prefixes=CHECK,NO_EXCEPTIONS
|
|
|
|
// RUN: %clang_cc1 -fexceptions %s -emit-llvm -triple x86_64-apple-macosx10.13.0 -o - | FileCheck %s --check-prefixes=CHECK,EXCEPTIONS
|
2018-08-22 01:24:06 +08:00
|
|
|
|
|
|
|
struct NonTrivial {
|
|
|
|
~NonTrivial();
|
|
|
|
};
|
|
|
|
|
|
|
|
// CHECK-NOT: __cxa_atexit{{.*}}_ZN10NonTrivialD1Ev
|
|
|
|
[[clang::no_destroy]] NonTrivial nt1;
|
|
|
|
// CHECK-NOT: _tlv_atexit{{.*}}_ZN10NonTrivialD1Ev
|
|
|
|
[[clang::no_destroy]] thread_local NonTrivial nt2;
|
|
|
|
|
|
|
|
struct NonTrivial2 {
|
|
|
|
~NonTrivial2();
|
|
|
|
};
|
|
|
|
|
2019-09-29 13:08:46 +08:00
|
|
|
// CHECK: __cxa_atexit{{.*}}_ZN11NonTrivial2D1Ev{{.*}}nt21
|
2018-08-22 01:24:06 +08:00
|
|
|
NonTrivial2 nt21;
|
2019-09-29 13:08:46 +08:00
|
|
|
// CHECK: _tlv_atexit{{.*}}_ZN11NonTrivial2D1Ev{{.*}}nt22
|
2018-08-22 01:24:06 +08:00
|
|
|
thread_local NonTrivial2 nt22;
|
|
|
|
|
2019-05-11 01:52:26 +08:00
|
|
|
// CHECK-LABEL: define void @_Z1fv
|
2018-08-22 01:24:06 +08:00
|
|
|
void f() {
|
|
|
|
// CHECK: __cxa_atexit{{.*}}_ZN11NonTrivial2D1Ev
|
|
|
|
static NonTrivial2 nt21;
|
|
|
|
// CHECK: _tlv_atexit{{.*}}_ZN11NonTrivial2D1Ev
|
|
|
|
thread_local NonTrivial2 nt22;
|
|
|
|
}
|
|
|
|
|
2019-05-11 01:52:26 +08:00
|
|
|
// CHECK-LABEL: define void @_Z1gv
|
|
|
|
void g() {
|
|
|
|
// CHECK-NOT: __cxa_atexit
|
|
|
|
[[clang::no_destroy]] static NonTrivial2 nt21;
|
|
|
|
// CHECK-NOT: _tlv_atexit
|
|
|
|
[[clang::no_destroy]] thread_local NonTrivial2 nt22;
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: define internal void @__cxx_global_var_init
|
2018-08-22 01:24:06 +08:00
|
|
|
// CHECK: __cxa_atexit{{.*}}_ZN10NonTrivialD1Ev
|
|
|
|
[[clang::always_destroy]] NonTrivial nt3;
|
2019-05-11 01:52:26 +08:00
|
|
|
// CHECK-LABEL: define internal void @__cxx_global_var_init
|
2018-08-22 01:24:06 +08:00
|
|
|
// CHECK: _tlv_atexit{{.*}}_ZN10NonTrivialD1Ev
|
|
|
|
[[clang::always_destroy]] thread_local NonTrivial nt4;
|
2019-05-11 01:52:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
struct NonTrivial3 {
|
|
|
|
NonTrivial3();
|
|
|
|
~NonTrivial3();
|
|
|
|
};
|
|
|
|
|
|
|
|
[[clang::no_destroy]] NonTrivial3 arr[10];
|
|
|
|
|
|
|
|
// CHECK-LABEL: define internal void @__cxx_global_var_init
|
|
|
|
// CHECK: {{invoke|call}} void @_ZN11NonTrivial3C1Ev
|
|
|
|
// EXCEPTIONS: call void @_ZN11NonTrivial3D1Ev
|
|
|
|
// NO_EXCEPTIONS-NOT: call void @_ZN11NonTrivial3D1Ev
|
|
|
|
// CHECK-NOT: call i32 @__cxa_atexit
|
|
|
|
|
|
|
|
void h() {
|
|
|
|
[[clang::no_destroy]] static NonTrivial3 slarr[10];
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: define void @_Z1hv
|
|
|
|
// CHECK: {{invoke|call}} void @_ZN11NonTrivial3C1Ev
|
|
|
|
// EXCEPTIONS: call void @_ZN11NonTrivial3D1Ev
|
|
|
|
// NO_EXCEPTIONS-NOT: call void @_ZN11NonTrivial3D1Ev
|
|
|
|
// CHECK-NOT: call i32 @__cxa_atexit
|
|
|
|
|
|
|
|
void i() {
|
|
|
|
[[clang::no_destroy]] thread_local NonTrivial3 tlarr[10];
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: define void @_Z1iv
|
|
|
|
// CHECK: {{invoke|call}} void @_ZN11NonTrivial3C1Ev
|
|
|
|
// EXCEPTIONS: call void @_ZN11NonTrivial3D1Ev
|
|
|
|
// NO_EXCEPTIONS-NOT: call void @_ZN11NonTrivial3D1Ev
|
|
|
|
// CHECK-NOT: _tlv_atexit
|