1 // RUN: %clang_cc1 -no-opaque-pointers -std=c++14 -fcoroutines-ts -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s
2 
3 #include "Inputs/coroutine-exp-namespace.h"
4 
5 namespace coro = std::experimental::coroutines_v1;
6 
7 struct coro1 {
8   struct promise_type {
9     coro1 get_return_object();
10     coro::suspend_never initial_suspend();
11     coro::suspend_never final_suspend() noexcept;
12     void return_void();
13   };
14 };
15 
f()16 coro1 f() {
17   co_await coro::suspend_never{};
18 }
19 
20 // CHECK-LABEL: define{{.*}} void @_Z1fv(
21 // CHECK: call void @_ZNSt12experimental13coroutines_v113suspend_never12await_resumeEv(%"struct.std::experimental::coroutines_v1::suspend_never"*
22 // CHECK: call void @_ZN5coro112promise_type11return_voidEv(%"struct.coro1::promise_type"* {{[^,]*}} %__promise)
23 
24 struct A {
25   A();
26   ~A();
27 };
28 
f2()29 coro1 f2() {
30   co_return(void) A{};
31 }
32 
33 // CHECK-LABEL: define{{.*}} void @_Z2f2v(
34 // CHECK: call void @_ZN1AC1Ev(%struct.A* {{[^,]*}} %[[AVar:.*]])
35 // CHECK-NEXT: call void @_ZN1AD1Ev(%struct.A* {{[^,]*}} %[[AVar]])
36 // CHECK-NEXT: call void @_ZN5coro112promise_type11return_voidEv(%"struct.coro1::promise_type"*
37 
38 struct coro2 {
39   struct promise_type {
40     coro2 get_return_object();
41     coro::suspend_never initial_suspend();
42     coro::suspend_never final_suspend() noexcept;
43     void return_value(int);
44   };
45 };
46 
g()47 coro2 g() {
48   co_return 42;
49 }
50 
51 // CHECK-LABEL: define{{.*}} void @_Z1gv(
52 // CHECK: call void @_ZNSt12experimental13coroutines_v113suspend_never12await_resumeEv(%"struct.std::experimental::coroutines_v1::suspend_never"*
53 // CHECK: call void @_ZN5coro212promise_type12return_valueEi(%"struct.coro2::promise_type"* {{[^,]*}} %__promise, i32 noundef 42)
54