1 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -ast-dump %s | FileCheck %s
3 #include "Inputs/std-coroutine.h"
9 Task
get_return_object() noexcept
{
10 return Task
{coroutine_handle
<promise_type
>::from_promise(*this)};
13 void return_void() noexcept
{}
15 struct final_awaiter
{
16 bool await_ready() noexcept
{ return false; }
17 coroutine_handle
<> await_suspend(coroutine_handle
<promise_type
> h
) noexcept
{
21 void await_resume() noexcept
{}
24 void unhandled_exception() noexcept
{}
26 final_awaiter
final_suspend() noexcept
{ return {}; }
28 suspend_always
initial_suspend() noexcept
{ return {}; }
30 template <typename Awaitable
>
31 auto await_transform(Awaitable
&&awaitable
) {
32 return awaitable
.co_viaIfAsync();
36 using handle_t
= coroutine_handle
<promise_type
>;
40 explicit Awaiter(handle_t coro
) noexcept
;
41 Awaiter(Awaiter
&&other
) noexcept
;
42 Awaiter(const Awaiter
&) = delete;
45 bool await_ready() noexcept
{ return false; }
46 handle_t
await_suspend(coroutine_handle
<> continuation
) noexcept
;
53 Task(handle_t coro
) noexcept
: coro_(coro
) {}
57 Task(const Task
&t
) = delete;
58 Task(Task
&&t
) noexcept
;
60 Task
&operator=(Task t
) noexcept
;
62 Awaiter
co_viaIfAsync();
83 // CHECK-LABEL: FunctionDecl {{.*}} bar 'Task ()'
86 // CHECK: ExprWithCleanups {{.*}} 'void'
87 // CHECK-NEXT: CoawaitExpr
88 // CHECK-NEXT: CXXBindTemporaryExpr {{.*}} 'Task' (CXXTemporary {{.*}})
89 // CHECK: MaterializeTemporaryExpr {{.*}} 'Awaiter':'Task::Awaiter'
90 // CHECK: ExprWithCleanups {{.*}} 'bool'
91 // CHECK-NEXT: CXXMemberCallExpr {{.*}} 'bool'
92 // CHECK-NEXT: MemberExpr {{.*}} .await_ready
93 // CHECK: ExprWithCleanups {{.*}} 'void *'
96 // CHECK: ExprWithCleanups {{.*}} 'void'
97 // CHECK-NEXT: CoawaitExpr
98 // CHECK-NEXT: CXXBindTemporaryExpr {{.*}} 'Task' (CXXTemporary {{.*}})
99 // CHECK: MaterializeTemporaryExpr {{.*}} 'Awaiter':'Task::Awaiter'
100 // CHECK: ExprWithCleanups {{.*}} 'bool'
101 // CHECK-NEXT: CXXMemberCallExpr {{.*}} 'bool'
102 // CHECK-NEXT: MemberExpr {{.*}} .await_ready
103 // CHECK: ExprWithCleanups {{.*}} 'void *'