Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / AST / ast-dump-coroutine.cpp
blob39a6e7e5a3eeec7680f121ab05a7f3aa7daf77e2
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"
6 using namespace std;
8 struct Task {
9 struct promise_type {
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) {
19 struct awaiter {
20 promise_type *promise;
21 bool await_ready() { return true; }
22 int await_resume() { return 1; }
23 void await_suspend(std::coroutine_handle<>) {}
26 return awaiter{this};
30 Task(std::coroutine_handle<promise_type> promise);
32 std::coroutine_handle<promise_type> handle;
35 Task test() {
36 co_await 1;
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
54 // ...
55 // CHECK: CoreturnStmt {{.*}} <col:6> implicit
57 Task test2() {
58 // Writen souce code, verify no implicit bit for the co_return expr.
59 // CHECK: CompoundStmt {{.*}}
60 // CHECK-NEXT: | `-CoreturnStmt {{.*}} <line:{{.*}}:{{.*}}>{{$}}
61 co_return;
63 // Verify the implicit AST nodes for coroutines.
64 // CHECK: |-DeclStmt {{.*}}
65 // CHECK-NEXT: | `-VarDecl {{.*}} implicit used __promise
66 // ...
67 // CHECK: CoreturnStmt {{.*}} <col:6> implicit