1 // Verify that we synthesized the coroutine for a lambda inside of a function template.
2 // RUN: %clang_cc1 -std=c++20 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s -fexceptions -fcxx-exceptions -disable-llvm-passes | FileCheck %s
5 template <typename R
, typename
... T
> struct coroutine_traits
{
6 using promise_type
= typename
R::promise_type
;
9 template <class Promise
= void> struct coroutine_handle
;
10 template <> struct coroutine_handle
<void> {
11 static coroutine_handle
from_address(void *) noexcept
;
12 coroutine_handle() = default;
13 template <class PromiseType
>
14 coroutine_handle(coroutine_handle
<PromiseType
>) noexcept
;
16 template <class Promise
> struct coroutine_handle
: coroutine_handle
<void> {
17 coroutine_handle() = default;
18 static coroutine_handle
from_address(void *) noexcept
;
22 struct suspend_always
{
23 bool await_ready() noexcept
;
24 void await_suspend(std::coroutine_handle
<>) noexcept
;
25 void await_resume() noexcept
;
30 Task
get_return_object();
32 suspend_always
initial_suspend() noexcept
;
33 suspend_always
final_suspend() noexcept
;
34 void unhandled_exception() noexcept
;
38 template <typename _AwrT
> auto SyncAwait(_AwrT
&&A
) {
39 if (!A
.await_ready()) {
40 auto AwaitAsync
= [&]() -> Task
{
41 try { (void)(co_await A
); } catch (...) {}
43 Task t
= AwaitAsync();
45 return A
.await_resume();
53 // Verify that we synthesized the coroutine for a lambda inside SyncAwait
54 // CHECK-LABEL: define linkonce_odr void @_ZZ9SyncAwaitIR14suspend_alwaysEDaOT_ENKUlvE_clEv(
55 // CHECK: alloca %"struct.Task::promise_type"
56 // CHECK: call token @llvm.coro.id(
57 // CHECK: call i8 @llvm.coro.suspend(
58 // CHECK: call i1 @llvm.coro.end(