| 1 |
// RUN: %clang_cc1 -fms-extensions -fms-compatibility-version=19.20 -triple x86_64-windows-msvc -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s --check-prefix=MSVC |
| 2 |
// RUN: %clang_cc1 -fms-extensions -fms-compatibility-version=19.20 -triple aarch64-windows-msvc -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s --check-prefix=MSVC |
| 3 |
// RUN: %clang_cc1 -triple x86_64-windows-itanium -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s --check-prefix=ITANIUM |
| 4 |
// RUN: %clang_cc1 -triple aarch64-windows-gnu -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s --check-prefix=GNU |
| 5 |
|
| 6 |
void foo1() { throw 1; } |
| 7 |
// _CxxThrowException should not be marked dllimport. |
| 8 |
// MSVC-LABEL: define dso_local void @"?foo1@@YAXXZ" |
| 9 |
// MSVC: call void @_CxxThrowException |
| 10 |
// MSVC: declare dso_local void @_CxxThrowException(ptr, ptr) |
| 11 |
|
| 12 |
// __cxa_throw should be marked dllimport for *-windows-itanium. |
| 13 |
// ITANIUM-LABEL: define dso_local void @_Z4foo1v() |
| 14 |
// ITANIUM: call void @__cxa_throw({{.*}}) |
| 15 |
// ITANIUM: declare dllimport void @__cxa_throw({{.*}}) |
| 16 |
|
| 17 |
// ... but not for *-windows-gnu. |
| 18 |
// GNU-LABEL: define dso_local void @_Z4foo1v() |
| 19 |
// GNU: call void @__cxa_throw({{.*}}) |
| 20 |
// GNU: declare dso_local void @__cxa_throw({{.*}}) |
| 21 |
|
| 22 |
|
| 23 |
void bar(); |
| 24 |
void foo2() noexcept(true) { bar(); } |
| 25 |
// __std_terminate should not be marked dllimport. |
| 26 |
// MSVC-LABEL: define dso_local void @"?foo2@@YAXXZ" |
| 27 |
// MSVC: call void @__std_terminate() |
| 28 |
// MSVC: declare dso_local void @__std_terminate() |
| 29 |
|
| 30 |
// _ZSt9terminatev and __cxa_begin_catch should be marked dllimport. |
| 31 |
// ITANIUM-LABEL: define linkonce_odr hidden void @__clang_call_terminate(ptr noundef %0) |
| 32 |
// ITANIUM: call ptr @__cxa_begin_catch({{.*}}) |
| 33 |
// ITANIUM: call void @_ZSt9terminatev() |
| 34 |
// ITANIUM: declare dllimport ptr @__cxa_begin_catch(ptr) |
| 35 |
// ITANIUM: declare dllimport void @_ZSt9terminatev() |
| 36 |
|
| 37 |
// .. not for mingw. |
| 38 |
// GNU-LABEL: define linkonce_odr hidden void @__clang_call_terminate(ptr noundef %0) |
| 39 |
// GNU: call ptr @__cxa_begin_catch({{.*}}) |
| 40 |
// GNU: call void @_ZSt9terminatev() |
| 41 |
// GNU: declare dso_local ptr @__cxa_begin_catch(ptr) |
| 42 |
// GNU: declare dso_local void @_ZSt9terminatev() |
| 43 |
|
| 44 |
|
| 45 |
struct A {}; |
| 46 |
struct B { virtual void f(); }; |
| 47 |
struct C : A, virtual B {}; |
| 48 |
struct T {}; |
| 49 |
T *foo3() { return dynamic_cast<T *>((C *)0); } |
| 50 |
// __RTDynamicCast should not be marked dllimport. |
| 51 |
// MSVC-LABEL: define dso_local noundef ptr @"?foo3@@YAPEAUT@@XZ" |
| 52 |
// MSVC: call ptr @__RTDynamicCast({{.*}}) |
| 53 |
// MSVC: declare dso_local ptr @__RTDynamicCast(ptr, i32, ptr, ptr, i32) |
| 54 |
|
| 55 |
// Again, imported |
| 56 |
// ITANIUM-LABEL: define dso_local noundef ptr @_Z4foo3v() |
| 57 |
// ITANIUM: call ptr @__dynamic_cast({{.*}}) |
| 58 |
// ITANIUM: declare dllimport ptr @__dynamic_cast({{.*}}) |
| 59 |
|
| 60 |
// Not imported |
| 61 |
// GNU-LABEL: define dso_local noundef ptr @_Z4foo3v() |
| 62 |
// GNU: call ptr @__dynamic_cast({{.*}}) |
| 63 |
// GNU: declare dso_local ptr @__dynamic_cast({{.*}}) |