[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGenCoroutines / coro-ret-void.cpp
blob73caba114cc6000ef6ec0ec491cae8be484a8471
1 // RUN: %clang_cc1 -std=c++20 -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s
3 #include "Inputs/coroutine.h"
5 struct coro1 {
6 struct promise_type {
7 coro1 get_return_object();
8 std::suspend_never initial_suspend();
9 std::suspend_never final_suspend() noexcept;
10 void return_void();
11 void unhandled_exception() noexcept;
15 coro1 f() {
16 co_await std::suspend_never{};
19 // CHECK-LABEL: define{{.*}} void @_Z1fv(
20 // CHECK: call void @_ZNSt13suspend_never12await_resumeEv(ptr
21 // CHECK: call void @_ZN5coro112promise_type11return_voidEv(ptr {{[^,]*}} %__promise)
23 struct A {
24 A();
25 ~A();
28 coro1 f2() {
29 co_return (void) A{};
32 // CHECK-LABEL: define{{.*}} void @_Z2f2v(
33 // CHECK: call void @_ZN1AC1Ev(ptr {{[^,]*}} %[[AVar:.*]])
34 // CHECK-NEXT: call void @_ZN1AD1Ev(ptr {{[^,]*}} %[[AVar]])
35 // CHECK-NEXT: call void @_ZN5coro112promise_type11return_voidEv(ptr
37 struct coro2 {
38 struct promise_type {
39 coro2 get_return_object();
40 std::suspend_never initial_suspend();
41 std::suspend_never final_suspend() noexcept;
42 void return_value(int);
43 void unhandled_exception() noexcept;
47 coro2 g() {
48 co_return 42;
51 // CHECK-LABEL: define{{.*}} void @_Z1gv(
52 // CHECK: call void @_ZNSt13suspend_never12await_resumeEv(ptr
53 // CHECK: call void @_ZN5coro212promise_type12return_valueEi(ptr {{[^,]*}} %__promise, i32 noundef 42)