[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / clang / test / CodeGenCXX / no_destroy.cpp
blobe1607f6a65103c902577bfe5d2430bd58fff57d0
1 // RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-macosx10.13.0 -o - | FileCheck %s --check-prefixes=CHECK,NO_EXCEPTIONS
2 // RUN: %clang_cc1 -fexceptions %s -emit-llvm -triple x86_64-apple-macosx10.13.0 -o - | FileCheck %s --check-prefixes=CHECK,EXCEPTIONS
4 struct NonTrivial {
5 ~NonTrivial();
6 };
8 // CHECK-NOT: __cxa_atexit{{.*}}_ZN10NonTrivialD1Ev
9 [[clang::no_destroy]] NonTrivial nt1;
10 // CHECK-NOT: _tlv_atexit{{.*}}_ZN10NonTrivialD1Ev
11 [[clang::no_destroy]] thread_local NonTrivial nt2;
13 struct NonTrivial2 {
14 ~NonTrivial2();
17 // CHECK: __cxa_atexit{{.*}}_ZN11NonTrivial2D1Ev{{.*}}nt21
18 NonTrivial2 nt21;
19 // CHECK: _tlv_atexit{{.*}}_ZN11NonTrivial2D1Ev{{.*}}nt22
20 thread_local NonTrivial2 nt22;
22 // CHECK-LABEL: define{{.*}} void @_Z1fv
23 void f() {
24 // CHECK: __cxa_atexit{{.*}}_ZN11NonTrivial2D1Ev
25 static NonTrivial2 nt21;
26 // CHECK: _tlv_atexit{{.*}}_ZN11NonTrivial2D1Ev
27 thread_local NonTrivial2 nt22;
30 // CHECK-LABEL: define{{.*}} void @_Z1gv
31 void g() {
32 // CHECK-NOT: __cxa_atexit
33 [[clang::no_destroy]] static NonTrivial2 nt21;
34 // CHECK-NOT: _tlv_atexit
35 [[clang::no_destroy]] thread_local NonTrivial2 nt22;
38 // CHECK-LABEL: define internal void @__cxx_global_var_init
39 // CHECK: __cxa_atexit{{.*}}_ZN10NonTrivialD1Ev
40 [[clang::always_destroy]] NonTrivial nt3;
41 // CHECK-LABEL: define internal void @__cxx_global_var_init
42 // CHECK: _tlv_atexit{{.*}}_ZN10NonTrivialD1Ev
43 [[clang::always_destroy]] thread_local NonTrivial nt4;
46 struct NonTrivial3 {
47 NonTrivial3();
48 ~NonTrivial3();
51 [[clang::no_destroy]] NonTrivial3 arr[10];
53 // CHECK-LABEL: define internal void @__cxx_global_var_init
54 // CHECK: {{invoke|call}} void @_ZN11NonTrivial3C1Ev
55 // EXCEPTIONS: call void @_ZN11NonTrivial3D1Ev
56 // NO_EXCEPTIONS-NOT: call void @_ZN11NonTrivial3D1Ev
57 // CHECK-NOT: call i32 @__cxa_atexit
59 void h() {
60 [[clang::no_destroy]] static NonTrivial3 slarr[10];
63 // CHECK-LABEL: define{{.*}} void @_Z1hv
64 // CHECK: {{invoke|call}} void @_ZN11NonTrivial3C1Ev
65 // EXCEPTIONS: call void @_ZN11NonTrivial3D1Ev
66 // NO_EXCEPTIONS-NOT: call void @_ZN11NonTrivial3D1Ev
67 // CHECK-NOT: call i32 @__cxa_atexit
69 void i() {
70 [[clang::no_destroy]] thread_local NonTrivial3 tlarr[10];
73 // CHECK-LABEL: define{{.*}} void @_Z1iv
74 // CHECK: {{invoke|call}} void @_ZN11NonTrivial3C1Ev
75 // EXCEPTIONS: call void @_ZN11NonTrivial3D1Ev
76 // NO_EXCEPTIONS-NOT: call void @_ZN11NonTrivial3D1Ev
77 // CHECK-NOT: _tlv_atexit