1 // Verify that we synthesized the coroutine for a lambda inside of a function template.
2 // RUN: %clang_cc1 -std=c++1z -fcoroutines-ts -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s -fexceptions -fcxx-exceptions -disable-llvm-passes | FileCheck %s
4 namespace std::experimental
{
5 template <typename R
, typename
... T
> struct coroutine_traits
{
6 using promise_type
= typename
R::promise_type
;
9 template <class Promise
= void> struct coroutine_handle
;
10 template <> struct coroutine_handle
<void> {
11 static coroutine_handle
from_address(void *) noexcept
;
12 coroutine_handle() = default;
13 template <class PromiseType
>
14 coroutine_handle(coroutine_handle
<PromiseType
>) noexcept
;
16 template <class Promise
> struct coroutine_handle
: coroutine_handle
<void> {
17 coroutine_handle() = default;
18 static coroutine_handle
from_address(void *) noexcept
;
20 } // namespace std::experimental
22 struct suspend_always
{
23 bool await_ready() noexcept
;
24 void await_suspend(std::experimental::coroutine_handle
<>) noexcept
;
25 void await_resume() noexcept
;
30 Task
get_return_object();
32 suspend_always
initial_suspend() noexcept
;
33 suspend_always
final_suspend() noexcept
;
34 void unhandled_exception() noexcept
;
38 template <typename _AwrT
> auto SyncAwait(_AwrT
&&A
) {
39 if (!A
.await_ready()) {
40 auto AwaitAsync
= [&]() -> Task
{
46 Task t
= AwaitAsync();
48 return A
.await_resume();
56 // Verify that we synthesized the coroutine for a lambda inside SyncAwait
57 // CHECK-LABEL: define linkonce_odr void @_ZZ9SyncAwaitIR14suspend_alwaysEDaOT_ENKUlvE_clEv(
58 // CHECK: alloca %"struct.Task::promise_type"
59 // CHECK: call token @llvm.coro.id(
60 // CHECK: call i8 @llvm.coro.suspend(
61 // CHECK: call i1 @llvm.coro.end(