[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenCXX / runtime-dllstorage.cpp
blobaa0e8172ca0f37bd0d78f90b9dabb82512f787ed
1 // RUN: %clang_cc1 -triple i686-windows-msvc -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-MS -check-prefix CHECK-MS-DYNAMIC
2 // RUN: %clang_cc1 -triple i686-windows-msvc -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-MS -check-prefix CHECK-MS-STATIC
4 // RUN: %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA -check-prefix CHECK-DYNAMIC-NODECL-IA
5 // RUN: %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA -check-prefix CHECK-STATIC-NODECL-IA
6 // RUN: %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -DIMPORT_DECLARATIONS -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA -check-prefix CHECK-DYNAMIC-IMPORT-IA
7 // RUN: %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std -DIMPORT_DECLARATIONS -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA -check-prefix CHECK-STATIC-IMPORT-IA
8 // RUN: %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -DEXPORT_DECLARATIONS -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA
9 // RUN: %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std -DEXPORT_DECLARATIONS -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA
10 // RUN: %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -DDECL -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA -check-prefix CHECK-DYNAMIC-DECL-IA
11 // RUN: %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std -DDECL -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA -check-prefix CHECK-STATIC-DECL-IA
12 // %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -fno-use-cxa-atexit -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-DYNAMIC-IA -check-prefix CHECK-DYNAMIC-IA-ATEXIT
13 // %clang_cc1 -triple i686-windows-itanium -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -fno-use-cxa-atexit -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA -check-prefix CHECK-STATIC-IA-ATEXIT
15 // RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA
16 // RUN: %clang_cc1 -triple i686-windows-gnu -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA
17 // RUN: %clang_cc1 -triple i686-windows-cygnus -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA
18 // RUN: %clang_cc1 -triple i686-windows-cygnus -std=c++11 -fdeclspec -fms-compatibility -fexceptions -fcxx-exceptions -flto-visibility-public-std -emit-llvm -o - %s | FileCheck -allow-deprecated-dag-overlap %s -check-prefix CHECK-IA -check-prefix CHECK-STATIC-IA
20 #if defined(IMPORT_DECLARATIONS)
21 namespace __cxxabiv1 {
22 extern "C" {
23 __declspec(dllimport) void __cxa_guard_acquire(unsigned long long *);
24 __declspec(dllimport) unsigned char *__cxa_allocate_exception(unsigned long);
26 extern "C" __declspec(dllimport) void __cxa_guard_release(unsigned long long *);
28 namespace std {
29 __declspec(dllimport) __declspec(noreturn) void terminate();
31 #elif defined(EXPORT_DECLARATIONS)
32 namespace __cxxabiv1 {
33 extern "C" {
34 __declspec(dllexport) void __cxa_guard_acquire(unsigned long long *);
35 __declspec(dllexport) unsigned char *__cxa_allocate_exception(unsigned long);
37 extern "C" void __declspec(dllexport) __cxa_guard_release(unsigned long long *);
39 namespace std {
40 __declspec(dllexport) __declspec(noreturn) void terminate();
42 #elif defined(DECL)
43 namespace __cxxabiv1 {
44 extern "C" unsigned char *__cxa_allocate_exception(unsigned long);
46 namespace std {
47 __declspec(noreturn) void terminate();
49 #else
50 namespace std {
51 __declspec(noreturn) void terminate();
53 #endif
55 struct s {
56 s() = default;
57 s(unsigned char) { throw 0; }
58 int m() const;
61 struct t {
62 ~t();
63 int m() const;
66 struct u {
67 ~u();
70 s o;
71 thread_local t t;
72 u v;
73 __declspec(thread) s q;
75 void __declspec(noinline) f() {
76 throw 0;
79 void g();
80 void __declspec(noinline) h() {
81 try {
82 g();
83 } catch (const int &) {
84 return;
85 } catch (...) {
86 throw;
90 void i() {
91 s r(static_cast<unsigned char>('\t'));
94 int j() {
95 static thread_local struct t v;
96 static struct t *w = new struct t;
97 return w->m() ? v.m() : w->m();
100 void k() noexcept {
101 g();
104 void l() {
105 std::terminate();
108 // CHECK-MS-DAG: @_Init_thread_epoch = external thread_local global i32
109 // CHECK-MS-DAG: declare dso_local i32 @__tlregdtor(ptr)
110 // CHECK-MS-DAG: declare dso_local i32 @atexit(ptr)
111 // CHECK-MS-DYNAMIC-DAG: declare {{.*}} void @_CxxThrowException
112 // CHECK-MS-STATIC-DAG: declare {{.*}} void @_CxxThrowException
113 // CHECK-MS-DAG: declare dso_local noundef nonnull ptr @"??2@YAPAXI@Z"
114 // CHECK-MS-DAG: declare dso_local void @_Init_thread_header(ptr)
115 // CHECK-MS-DAG: declare dso_local void @_Init_thread_footer(ptr)
117 // CHECK-IA-DAG: @_ZTH1t = dso_local alias void (), ptr @__tls_init
118 // CHECK-IA-DAG: declare dso_local i32 @__gxx_personality_v0(...)
119 // CHECK-IA-DAG: define linkonce_odr hidden void @__clang_call_terminate(ptr noundef %0)
121 // CHECK-DYNAMIC-IA-DAG: declare dllimport i32 @__cxa_thread_atexit(ptr, ptr, ptr)
122 // CHECK-DYNAMIC-IA-DAG: declare dllimport i32 @__cxa_atexit(ptr, ptr, ptr)
123 // CHECK-DYNAMIC-IA-DECL-DAG: declare ptr @__cxa_allocate_exception(i32 noundef)
124 // CHECK-DYNAMIC-IA-NODECL-DAG: declare dllimport ptr @__cxa_allocate_exception(i32 noundef)
125 // CHECK-DYNAMIC-IA-IMPORT-DAG: declare dllimport ptr @__cxa_allocate_exception(i32 noundef)
126 // CHECK-DYNAMIC-IA-EXPORT-DAG: declare dllimport ptr @__cxa_allocate_exception(i32 noundef)
127 // CHECK-DYNAMIC-IA-DAG: declare dllimport void @__cxa_throw(ptr, ptr, ptr)
128 // CHECK-DYNAMIC-DECL-IA-DAG: declare dllimport i32 @__cxa_guard_acquire(ptr)
129 // CHECK-DYNAMIC-NODECL-IA-DAG: declare dllimport i32 @__cxa_guard_acquire(ptr)
130 // CHECK-DYNAMIC-IMPORT-IA-DAG: declare dllimport i32 @__cxa_guard_acquire(ptr)
131 // CHECK-DYNAMIC-EXPORT-IA-DAG: declare dllexport i32 @__cxa_guard_acquire(ptr)
132 // CHECK-IA-DAG: declare dso_local noundef nonnull ptr @_Znwj(i32 noundef)
133 // CHECK-DYNAMIC-DECL-IA-DAG: declare dllimport void @__cxa_guard_release(ptr)
134 // CHECK-DYNAMIC-NODECL-IA-DAG: declare dllimport void @__cxa_guard_release(ptr)
135 // CHECK-DYNAMIC-IMPORT-IA-DAG: declare dllimport void @__cxa_guard_release(ptr)
136 // CHECK-DYNAMIC-EXPORT-IA-DAG: declare dllimport void @__cxa_guard_release(ptr)
137 // CHECK-DYANMIC-IA-DAG: declare dllimport void @_ZSt9terminatev()
138 // CHECK-DYNAMIC-NODECL-IA-DAG: declare dso_local void @_ZSt9terminatev()
139 // CHECK-DYNAMIC-IMPORT-IA-DAG: declare dllimport void @_ZSt9terminatev()
140 // CHECK-DYNAMIC-EXPORT-IA-DAG: declare dso_local dllexport void @_ZSt9terminatev()
142 // CHECK-STATIC-IA-DAG: declare dso_local i32 @__cxa_thread_atexit(ptr, ptr, ptr)
143 // CHECK-STATIC-IA-DAG: declare dso_local i32 @__cxa_atexit(ptr, ptr, ptr)
144 // CHECK-STATIC-IA-DAG: declare dso_local ptr @__cxa_allocate_exception(i32)
145 // CHECK-STATIC-IA-DAG: declare dso_local void @__cxa_throw(ptr, ptr, ptr)
146 // CHECK-STATIC-DECL-IA-DAG: declare dso_local i32 @__cxa_guard_acquire(ptr)
147 // CHECK-STATIC-NODECL-IA-DAG: declare dso_local i32 @__cxa_guard_acquire(ptr)
148 // CHECK-STATIC-IMPORT-IA-DAG: declare dso_local i32 @__cxa_guard_acquire(ptr)
149 // CHECK-STATIC-EXPORT-IA-DAG: declare dso_local i32 @__cxa_guard_acquire(ptr)
150 // CHECK-IA-DAG: declare dso_local noundef nonnull ptr @_Znwj(i32 noundef)
151 // CHECK-STATIC-DECL-IA-DAG: declare dso_local void @__cxa_guard_release(ptr)
152 // CHECK-STATIC-NODECL-IA-DAG: declare dso_local void @__cxa_guard_release(ptr)
153 // CHECK-STATIC-IMPORT-IA-DAG: declare dso_local void @__cxa_guard_release(ptr)
154 // CHECK-STATIC-EXPORT-IA-DAG: declare dso_local void @__cxa_guard_release(ptr)
155 // CHECK-STATIC-IA-DAG: declare dso_local void @_ZSt9terminatev()
156 // CHECK-STATIC-NODECL-IA-DAG: declare dso_local void @_ZSt9terminatev()
157 // CHECK-STATIC-IMPORT-IA-DAG: declare dso_local void @_ZSt9terminatev()
158 // CHECK-STATIC-EXPORT-IA-DAG: declare dso_local dllexport void @_ZSt9terminatev()