1 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -fsyntax-only -ast-dump %s | FileCheck %s
3 #include "Inputs/std-coroutine-exp-namespace.h"
5 using namespace std::experimental
;
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':'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: CallExpr {{.*}} 'void'
94 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'void (*)(void *)'
95 // CHECK-NEXT: DeclRefExpr {{.*}} '__builtin_coro_resume' 'void (void *)'
96 // CHECK-NEXT: ExprWithCleanups {{.*}} 'void *'
99 // CHECK: ExprWithCleanups {{.*}} 'void'
100 // CHECK-NEXT: CoawaitExpr
101 // CHECK-NEXT: CXXBindTemporaryExpr {{.*}} 'Task':'Task' (CXXTemporary {{.*}})
102 // CHECK: MaterializeTemporaryExpr {{.*}} 'Awaiter':'Task::Awaiter'
103 // CHECK: ExprWithCleanups {{.*}} 'bool'
104 // CHECK-NEXT: CXXMemberCallExpr {{.*}} 'bool'
105 // CHECK-NEXT: MemberExpr {{.*}} .await_ready
106 // CHECK: CallExpr {{.*}} 'void'
107 // CHECK-NEXT: ImplicitCastExpr {{.*}} 'void (*)(void *)'
108 // CHECK-NEXT: DeclRefExpr {{.*}} '__builtin_coro_resume' 'void (void *)'
109 // CHECK-NEXT: ExprWithCleanups {{.*}} 'void *'