1 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s
3 #include "Inputs/coroutine-exp-namespace.h"
5 using namespace std::experimental
;
10 constexpr nothrow_t nothrow
= {};
12 } // end namespace std
14 // Required when get_return_object_on_allocation_failure() is defined by
16 void *operator new(__SIZE_TYPE__ __sz
, const std::nothrow_t
&) noexcept
;
17 void operator delete(void *__p
, const std::nothrow_t
&)noexcept
;
19 template <class RetObject
>
21 RetObject
get_return_object();
22 suspend_always
initial_suspend();
23 suspend_never
final_suspend() noexcept
;
25 static void unhandled_exception();
29 using promise_type
= promise_type
<coro
>;
35 // Verify that the RVO is applied.
36 // CHECK-LABEL: define{{.*}} void @_Z1fi(%struct.coro* noalias sret(%struct.coro) align 8 %agg.result, i32 noundef %0)
38 // CHECK: %call = call noalias noundef nonnull i8* @_Znwm(
39 // CHECK-NEXT: br label %[[CoroInit:.*]]
41 // CHECK: {{.*}}[[CoroInit]]:
42 // CHECK: call void @{{.*get_return_objectEv}}(%struct.coro* sret(%struct.coro) align 8 %agg.result
46 template <class RetObject
>
47 struct promise_type_with_on_alloc_failure
{
48 static RetObject
get_return_object_on_allocation_failure();
49 RetObject
get_return_object();
50 suspend_always
initial_suspend();
51 suspend_never
final_suspend() noexcept
;
53 static void unhandled_exception();
57 using promise_type
= promise_type_with_on_alloc_failure
<coro_two
>;
58 coro_two(coro_two
const &);
63 // Verify that the NRVO is applied to the Gro object.
64 // CHECK-LABEL: define{{.*}} void @_Z1hi(%struct.coro_two* noalias sret(%struct.coro_two) align 8 %agg.result, i32 noundef %0)
67 // CHECK: %call = call noalias noundef i8* @_ZnwmRKSt9nothrow_t
68 // CHECK-NEXT: %[[CheckNull:.*]] = icmp ne i8* %call, null
69 // CHECK-NEXT: br i1 %[[CheckNull]], label %[[InitOnSuccess:.*]], label %[[InitOnFailure:.*]]
71 // CHECK: {{.*}}[[InitOnFailure]]:
72 // CHECK-NEXT: call void @{{.*get_return_object_on_allocation_failureEv}}(%struct.coro_two* sret(%struct.coro_two) align 8 %agg.result
73 // CHECK-NEXT: br label %[[RetLabel:.*]]
75 // CHECK: {{.*}}[[InitOnSuccess]]:
76 // CHECK: call void @{{.*get_return_objectEv}}(%struct.coro_two* sret(%struct.coro_two) align 8 %agg.result
78 // CHECK: [[RetLabel]]:
79 // CHECK-NEXT: ret void