[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenCoroutines / coro-unhandled-exception.cpp
blob0d253d9045c2bb798cead6b2a9ea48a8f45e01b5
1 // RUN: %clang_cc1 -no-opaque-pointers -std=c++20 -triple=x86_64-pc-windows-msvc18.0.0 -emit-llvm %s -o - -fexceptions -fcxx-exceptions -disable-llvm-passes | FileCheck %s
2 // RUN: %clang_cc1 -no-opaque-pointers -std=c++20 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s -fexceptions -fcxx-exceptions -disable-llvm-passes | FileCheck --check-prefix=CHECK-LPAD %s
4 #include "Inputs/coroutine.h"
6 namespace std {
7 using exception_ptr = int;
8 exception_ptr current_exception();
11 struct coro_t {
12 struct promise_type {
13 coro_t get_return_object() {
14 std::coroutine_handle<promise_type>{};
15 return {};
17 std::suspend_never initial_suspend() { return {}; }
18 std::suspend_never final_suspend() noexcept { return {}; }
19 void return_void(){}
20 void unhandled_exception() noexcept;
24 struct Cleanup { ~Cleanup(); };
25 void may_throw();
27 coro_t f() {
28 Cleanup x;
29 may_throw();
30 co_return;
33 // CHECK: @"?f@@YA?AUcoro_t@@XZ"(
34 // CHECK: invoke void @"?may_throw@@YAXXZ"()
35 // CHECK: to label %{{.+}} unwind label %[[EHCLEANUP:.+]]
36 // CHECK: [[EHCLEANUP]]:
37 // CHECK: %[[INNERPAD:.+]] = cleanuppad within none []
38 // CHECK: call void @"??1Cleanup@@QEAA@XZ"(
39 // CHECK: cleanupret from %[[INNERPAD]] unwind label %[[CATCHSW:.+]]
40 // CHECK: [[CATCHSW]]:
41 // CHECK: %[[CATCHSWTOK:.+]] = catchswitch within none [label %[[CATCH:.+]]] unwind label
42 // CHECK: [[CATCH]]:
43 // CHECK: %[[CATCHTOK:.+]] = catchpad within [[CATCHSWTOK:.+]]
44 // CHECK: call void @"?unhandled_exception@promise_type@coro_t@@QEAAXXZ"
45 // CHECK: catchret from %[[CATCHTOK]] to label %[[CATCHRETDEST:.+]]
46 // CHECK: [[CATCHRETDEST]]:
47 // CHECK-NEXT: br label %[[TRYCONT:.+]]
48 // CHECK: [[TRYCONT]]:
49 // CHECK-NEXT: br label %[[COROFIN:.+]]
50 // CHECK: [[COROFIN]]:
51 // CHECK-NEXT: bitcast %"struct.std::suspend_never"* %{{.+}} to i8*
52 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(
53 // CHECK-NEXT: call void @"?final_suspend@promise_type@coro_t@@QEAA?AUsuspend_never@std@@XZ"(
55 // CHECK-LPAD: @_Z1fv(
56 // CHECK-LPAD: invoke void @_Z9may_throwv()
57 // CHECK-LPAD: to label %[[CONT:.+]] unwind label %[[CLEANUP:.+]]
58 // CHECK-LPAD: [[CLEANUP]]:
59 // CHECK-LPAD: call void @_ZN7CleanupD1Ev(%struct.Cleanup* {{[^,]*}} %x) #2
60 // CHECK-LPAD: br label %[[CATCH:.+]]
62 // CHECK-LPAD: [[CATCH]]:
63 // CHECK-LPAD: call i8* @__cxa_begin_catch
64 // CHECK-LPAD: call void @_ZN6coro_t12promise_type19unhandled_exceptionEv(%"struct.coro_t::promise_type"* {{[^,]*}} %__promise) #2
65 // CHECK-LPAD: invoke void @__cxa_end_catch()
66 // CHECK-LPAD-NEXT: to label %[[CATCHRETDEST:.+]] unwind label
67 // CHECK-LPAD: [[CATCHRETDEST]]:
68 // CHECK-LPAD-NEXT: br label %[[TRYCONT:.+]]
69 // CHECK-LPAD: [[TRYCONT]]:
70 // CHECK-LPAD: br label %[[COROFIN:.+]]
71 // CHECK-LPAD: [[COROFIN]]:
72 // CHECK-LPAD-NEXT: bitcast %"struct.std::suspend_never"* %{{.+}} to i8*
73 // CHECK-LPAD-NEXT: call void @llvm.lifetime.start.p0i8(
74 // CHECK-LPAD-NEXT: call void @_ZN6coro_t12promise_type13final_suspendEv(