1 // RUN: %clang_cc1 -no-opaque-pointers -std=c++14 -fcoroutines-ts -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++14 -fcoroutines-ts -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-exp-namespace.h"
6 namespace coro
= std::experimental::coroutines_v1
;
9 using exception_ptr
= int;
10 exception_ptr
current_exception();
15 coro_t
get_return_object() {
16 coro::coroutine_handle
<promise_type
>{};
19 coro::suspend_never
initial_suspend() { return {}; }
20 coro::suspend_never
final_suspend() noexcept
{ return {}; }
22 void unhandled_exception() noexcept
;
37 // CHECK: @"?f@@YA?AUcoro_t@@XZ"(
38 // CHECK: invoke void @"?may_throw@@YAXXZ"()
39 // CHECK: to label %{{.+}} unwind label %[[EHCLEANUP:.+]]
40 // CHECK: [[EHCLEANUP]]:
41 // CHECK: %[[INNERPAD:.+]] = cleanuppad within none []
42 // CHECK: call void @"??1Cleanup@@QEAA@XZ"(
43 // CHECK: cleanupret from %[[INNERPAD]] unwind label %[[CATCHSW:.+]]
44 // CHECK: [[CATCHSW]]:
45 // CHECK: %[[CATCHSWTOK:.+]] = catchswitch within none [label %[[CATCH:.+]]] unwind label
47 // CHECK: %[[CATCHTOK:.+]] = catchpad within [[CATCHSWTOK:.+]]
48 // CHECK: call void @"?unhandled_exception@promise_type@coro_t@@QEAAXXZ"
49 // CHECK: catchret from %[[CATCHTOK]] to label %[[CATCHRETDEST:.+]]
50 // CHECK: [[CATCHRETDEST]]:
51 // CHECK-NEXT: br label %[[TRYCONT:.+]]
52 // CHECK: [[TRYCONT]]:
53 // CHECK-NEXT: br label %[[COROFIN:.+]]
54 // CHECK: [[COROFIN]]:
55 // CHECK-NEXT: bitcast %"struct.std::experimental::coroutines_v1::suspend_never"* %{{.+}} to i8*
56 // CHECK-NEXT: call void @llvm.lifetime.start.p0i8(
57 // CHECK-NEXT: call void @"?final_suspend@promise_type@coro_t@@QEAA?AUsuspend_never@coroutines_v1@experimental@std@@XZ"(
59 // CHECK-LPAD: @_Z1fv(
60 // CHECK-LPAD: invoke void @_Z9may_throwv()
61 // CHECK-LPAD: to label %[[CONT:.+]] unwind label %[[CLEANUP:.+]]
62 // CHECK-LPAD: [[CLEANUP]]:
63 // CHECK-LPAD: call void @_ZN7CleanupD1Ev(%struct.Cleanup* {{[^,]*}} %x) #2
64 // CHECK-LPAD: br label %[[CATCH:.+]]
66 // CHECK-LPAD: [[CATCH]]:
67 // CHECK-LPAD: call i8* @__cxa_begin_catch
68 // CHECK-LPAD: call void @_ZN6coro_t12promise_type19unhandled_exceptionEv(%"struct.coro_t::promise_type"* {{[^,]*}} %__promise) #2
69 // CHECK-LPAD: invoke void @__cxa_end_catch()
70 // CHECK-LPAD-NEXT: to label %[[CATCHRETDEST:.+]] unwind label
71 // CHECK-LPAD: [[CATCHRETDEST]]:
72 // CHECK-LPAD-NEXT: br label %[[TRYCONT:.+]]
73 // CHECK-LPAD: [[TRYCONT]]:
74 // CHECK-LPAD: br label %[[COROFIN:.+]]
75 // CHECK-LPAD: [[COROFIN]]:
76 // CHECK-LPAD-NEXT: bitcast %"struct.std::experimental::coroutines_v1::suspend_never"* %{{.+}} to i8*
77 // CHECK-LPAD-NEXT: call void @llvm.lifetime.start.p0i8(
78 // CHECK-LPAD-NEXT: call void @_ZN6coro_t12promise_type13final_suspendEv(