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 3 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 -check-prefix CHECK-DYNAMIC-IA-CXA-ATEXIT 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 -check-prefix CHECK-IA-STATIC-CXA-ATEXIT 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 -check-prefix CHECK-DYNAMIC-IA-CXA-ATEXIT 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 -check-prefix CHECK-IA-STATIC-CXA-ATEXIT 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 -check-prefix CHECK-DYNAMIC-IA-CXA-ATEXIT 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 -check-prefix CHECK-IA-STATIC-CXA-ATEXIT 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 -check-prefix CHECK-DYNAMIC-IA-CXA-ATEXIT 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 -check-prefix CHECK-IA-STATIC-CXA-ATEXIT 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 14 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 19 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); 25 } 26 extern "C" __declspec(dllimport) void __cxa_guard_release(unsigned long long *); 27 } 28 namespace std { 29 __declspec(dllimport) __declspec(noreturn) void terminate(); 30 } 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); 36 } 37 extern "C" void __declspec(dllexport) __cxa_guard_release(unsigned long long *); 38 } 39 namespace std { 40 __declspec(dllexport) __declspec(noreturn) void terminate(); 41 } 42 #elif defined(DECL) 43 namespace __cxxabiv1 { 44 extern "C" unsigned char *__cxa_allocate_exception(unsigned long); 45 } 46 namespace std { 47 __declspec(noreturn) void terminate(); 48 } 49 #else 50 namespace std { 51 __declspec(noreturn) void terminate(); 52 } 53 #endif 54 55 struct s { 56 s() = default; 57 s(unsigned char) { throw 0; } 58 int m() const; 59 }; 60 61 struct t { 62 ~t(); 63 int m() const; 64 }; 65 66 struct u { 67 ~u(); 68 }; 69 70 s o; 71 thread_local t t; 72 u v; 73 __declspec(thread) s q; 74 75 void __declspec(noinline) f() { 76 throw 0; 77 } 78 79 void g(); 80 void __declspec(noinline) h() { 81 try { 82 g(); 83 } catch (const int &) { 84 return; 85 } catch (...) { 86 throw; 87 } 88 } 89 90 void i() { 91 s r(static_cast<unsigned char>('\t')); 92 } 93 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(); 98 } 99 100 void k() noexcept { 101 g(); 102 } 103 104 void l() { 105 std::terminate(); 106 } 107 108 // CHECK-MS-DAG: @_Init_thread_epoch = external thread_local global i32 109 // CHECK-MS-DAG: declare dso_local i32 @__tlregdtor(void ()*) 110 // CHECK-MS-DAG: declare dso_local i32 @atexit(void ()*) 111 // CHECK-MS-DYNAMIC-DAG: declare {{.*}} void @_CxxThrowException 112 // CHECK-MS-STATIC-DAG: declare {{.*}} void @_CxxThrowException 113 // CHECK-MS-DAG: declare dso_local nonnull i8* @"??2@YAPAXI@Z" 114 // CHECK-MS-DAG: declare dso_local void @_Init_thread_header(i32*) 115 // CHECK-MS-DAG: declare dso_local void @_Init_thread_footer(i32*) 116 117 // CHECK-IA-DAG: @_ZTH1t = dso_local alias void (), void ()* @__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(i8* %0) 120 121 // CHECK-DYNAMIC-IA-DAG: declare dllimport i32 @__cxa_thread_atexit(void (i8*)*, i8*, i8*) 122 // CHECK-DYNAMIC-IA-DAG: declare dllimport i32 @__cxa_atexit(void (i8*)*, i8*, i8*) 123 // CHECK-DYNAMIC-IA-DECL-DAG: declare i8* @__cxa_allocate_exception(i32) 124 // CHECK-DYNAMIC-IA-NODECL-DAG: declare dllimport i8* @__cxa_allocate_exception(i32) 125 // CHECK-DYNAMIC-IA-IMPORT-DAG: declare dllimport i8* @__cxa_allocate_exception(i32) 126 // CHECK-DYNAMIC-IA-EXPORT-DAG: declare dllimport i8* @__cxa_allocate_exception(i32) 127 // CHECK-DYNAMIC-IA-DAG: declare dllimport void @__cxa_throw(i8*, i8*, i8*) 128 // CHECK-DYNAMIC-DECL-IA-DAG: declare dllimport i32 @__cxa_guard_acquire(i64*) 129 // CHECK-DYNAMIC-NODECL-IA-DAG: declare dllimport i32 @__cxa_guard_acquire(i64*) 130 // CHECK-DYNAMIC-IMPORT-IA-DAG: declare dllimport i32 @__cxa_guard_acquire(i64*) 131 // CHECK-DYNAMIC-EXPORT-IA-DAG: declare dllexport i32 @__cxa_guard_acquire(i64*) 132 // CHECK-IA-DAG: declare dso_local nonnull i8* @_Znwj(i32) 133 // CHECK-DYNAMIC-DECL-IA-DAG: declare dllimport void @__cxa_guard_release(i64*) 134 // CHECK-DYNAMIC-NODECL-IA-DAG: declare dllimport void @__cxa_guard_release(i64*) 135 // CHECK-DYNAMIC-IMPORT-IA-DAG: declare dllimport void @__cxa_guard_release(i64*) 136 // CHECK-DYNAMIC-EXPORT-IA-DAG: declare dllimport void @__cxa_guard_release(i64*) 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() 141 142 // CHECK-STATIC-IA-DAG: declare dso_local i32 @__cxa_thread_atexit(void (i8*)*, i8*, i8*) 143 // CHECK-STATIC-IA-DAG: declare dso_local i32 @__cxa_atexit(void (i8*)*, i8*, i8*) 144 // CHECK-STATIC-IA-DAG: declare dso_local i8* @__cxa_allocate_exception(i32) 145 // CHECK-STATIC-IA-DAG: declare dso_local void @__cxa_throw(i8*, i8*, i8*) 146 // CHECK-STATIC-DECL-IA-DAG: declare dso_local i32 @__cxa_guard_acquire(i64*) 147 // CHECK-STATIC-NODECL-IA-DAG: declare dso_local i32 @__cxa_guard_acquire(i64*) 148 // CHECK-STATIC-IMPORT-IA-DAG: declare dso_local i32 @__cxa_guard_acquire(i64*) 149 // CHECK-STATIC-EXPORT-IA-DAG: declare dso_local i32 @__cxa_guard_acquire(i64*) 150 // CHECK-IA-DAG: declare dso_local nonnull i8* @_Znwj(i32) 151 // CHECK-STATIC-DECL-IA-DAG: declare dso_local void @__cxa_guard_release(i64*) 152 // CHECK-STATIC-NODECL-IA-DAG: declare dso_local void @__cxa_guard_release(i64*) 153 // CHECK-STATIC-IMPORT-IA-DAG: declare dso_local void @__cxa_guard_release(i64*) 154 // CHECK-STATIC-EXPORT-IA-DAG: declare dso_local void @__cxa_guard_release(i64*) 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() 159