[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / CodeGenCoroutines / coro-unhandled-exception-exp-namespace.cpp
blob0bce7b1720dae2315ea1141bab8e7665fb017153
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;
8 namespace std {
9 using exception_ptr = int;
10 exception_ptr current_exception();
11 } // namespace std
13 struct coro_t {
14 struct promise_type {
15 coro_t get_return_object() {
16 coro::coroutine_handle<promise_type>{};
17 return {};
19 coro::suspend_never initial_suspend() { return {}; }
20 coro::suspend_never final_suspend() noexcept { return {}; }
21 void return_void() {}
22 void unhandled_exception() noexcept;
26 struct Cleanup {
27 ~Cleanup();
29 void may_throw();
31 coro_t f() {
32 Cleanup x;
33 may_throw();
34 co_return;
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
46 // CHECK: [[CATCH]]:
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(