[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGenCoroutines / coro-promise-dtor.cpp
blobafaaf876a81035fe9d93e3e9e7ca14c544f829da
1 // RUN: %clang_cc1 -std=c++20 -triple=x86_64-pc-windows-msvc18.0.0 -emit-llvm -o - %s -fexceptions -fcxx-exceptions -disable-llvm-passes | FileCheck %s
2 // -triple=x86_64-unknown-linux-gnu
4 #include "Inputs/coroutine.h"
6 struct coro_t {
7 void* p;
8 ~coro_t();
9 struct promise_type {
10 coro_t get_return_object();
11 std::suspend_never initial_suspend();
12 std::suspend_never final_suspend() noexcept;
13 void return_void();
14 promise_type();
15 ~promise_type();
16 void unhandled_exception();
20 struct Cleanup { ~Cleanup(); };
21 void may_throw();
23 coro_t f() {
24 Cleanup cleanup;
25 may_throw();
26 co_return;
29 // CHECK-LABEL: define dso_local void @"?f@@YA?AUcoro_t@@XZ"(
31 // CHECK: invoke noundef ptr @"??0promise_type@coro_t@@QEAA@XZ"(
32 // CHECK: invoke void @"?get_return_object@promise_type@coro_t@@QEAA?AU2@XZ"(
34 // CHECK: call void @"??1promise_type@coro_t@@QEAA@XZ"