Debian Codegraph @

clang/test/AST/coroutine-co_yield-source-range.cpp

raw
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 \
2 // RUN: -ast-dump | FileCheck %s
3
4 #include "Inputs/std-coroutine.h"
5
6 using namespace std;
7
8 struct Chat {
9 struct promise_type {
10 std::suspend_always initial_suspend() { return {}; }
11 Chat get_return_object() {
12 return std::coroutine_handle<promise_type>::from_promise(*this);
13 }
14 std::suspend_always yield_value(int m) { return {}; }
15 std::suspend_always final_suspend() noexcept { return {}; }
16 std::suspend_always return_value(int) { return {}; }
17 void unhandled_exception() {}
18
19 auto await_transform(int s) {
20 struct awaiter {
21 promise_type *promise;
22 bool await_ready() { return true; }
23 int await_resume() { return promise->message; }
24 void await_suspend(std::coroutine_handle<>) {}
25 };
26
27 return awaiter{this};
28 }
29 int message;
30 };
31
32 Chat(std::coroutine_handle<promise_type> promise);
33
34 std::coroutine_handle<promise_type> handle;
35 };
36
37 Chat f(int s) {
38 // CHECK: CoyieldExpr {{.*}} <col:3, col:12>
39 // CHECK-NEXT: CXXMemberCallExpr {{.*}} <col:3, col:12> {{.*}}
40 // CHECK-NEXT: MemberExpr {{.*}} <col:3> {{.*}}
41 // CHECK-NEXT: DeclRefExpr {{.*}} <col:3> {{.*}}
42 // CHECK-NEXT: ImplicitCastExpr {{.*}} <col:12> {{.*}}
43 // CHECK-NEXT: DeclRefExpr {{.*}} <col:12> {{.*}}
44 co_yield s;
45 // CHECK: CoreturnStmt {{.*}} <line:{{.*}}:3, col:13>
46 co_return s;
47 // CHECK: CoawaitExpr {{.*}} <col:3, col:12> 'int'
48 co_await s;
49 }