1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -std=c++20 \
2 // RUN: -ast-dump -ast-dump-filter test | FileCheck %s
4 #include "Inputs/std-coroutine.h"
10 std::suspend_always
initial_suspend() { return {}; }
11 Task
get_return_object() {
12 return std::coroutine_handle
<promise_type
>::from_promise(*this);
14 std::suspend_always
final_suspend() noexcept
{ return {}; }
15 std::suspend_always
return_void() { return {}; }
16 void unhandled_exception() {}
18 auto await_transform(int s
) {
20 promise_type
*promise
;
21 bool await_ready() { return true; }
22 int await_resume() { return 1; }
23 void await_suspend(std::coroutine_handle
<>) {}
30 Task(std::coroutine_handle
<promise_type
> promise
);
32 std::coroutine_handle
<promise_type
> handle
;
37 // Writen souce code, verify no implicit bit for the co_await expr.
38 // CHECK: CompoundStmt {{.*}}
39 // CHECK-NEXT: | `-ExprWithCleanups {{.*}} 'int'
40 // CHECK-NEXT: | `-CoawaitExpr {{.*}} 'int'{{$}}
41 // CHECK-NEXT: | |-IntegerLiteral {{.*}} <col:12> 'int' 1
42 // CHECK-NEXT: | |-MaterializeTemporaryExpr {{.*}} 'awaiter'
43 // CHECK-NEXT: | | `-CXXMemberCallExpr {{.*}} 'awaiter'
44 // CHECK-NEXT: | | |-MemberExpr {{.*}} .await_transform
46 // Verify the implicit AST nodes for coroutines.
47 // CHECK: |-DeclStmt {{.*}}
48 // CHECK-NEXT: | `-VarDecl {{.*}} implicit used __promise
49 // CHECK-NEXT: | `-CXXConstructExpr {{.*}}
50 // CHECK-NEXT: |-ExprWithCleanups {{.*}} 'void'
51 // CHECK-NEXT: | `-CoawaitExpr {{.*}} 'void' implicit
52 // CHECK-NEXT: |-CXXMemberCallExpr {{.*}} 'std::suspend_always'
53 // CHECK-NEXT: | | `-MemberExpr {{.*}} .initial_suspend
55 // CHECK: CoreturnStmt {{.*}} <col:6> implicit
58 // Writen souce code, verify no implicit bit for the co_return expr.
59 // CHECK: CompoundStmt {{.*}}
60 // CHECK-NEXT: | `-CoreturnStmt {{.*}} <line:{{.*}}:{{.*}}>{{$}}
63 // Verify the implicit AST nodes for coroutines.
64 // CHECK: |-DeclStmt {{.*}}
65 // CHECK-NEXT: | `-VarDecl {{.*}} implicit used __promise
67 // CHECK: CoreturnStmt {{.*}} <col:6> implicit