Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / AST / coroutine-co_yield-source-range.cpp
blobc5766a6d718940d67b16a7dc00d6c52d90e7d062
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 \
2 // RUN: -fsyntax-only -ast-dump | FileCheck %s
4 #include "Inputs/std-coroutine.h"
6 using namespace std;
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);
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() {}
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<>) {}
27 return awaiter{this};
29 int message;
32 Chat(std::coroutine_handle<promise_type> promise);
34 std::coroutine_handle<promise_type> handle;
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;