summaryrefslogtreecommitdiff
path: root/test/CodeGenCoroutines
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2017-04-18 03:12:48 +0000
committerEric Fiselier <eric@efcs.ca>2017-04-18 03:12:48 +0000
commitbe42922df5c37b5707852b64de120f52c3f8c1a9 (patch)
tree90b97ca5a3c4a09a32b96671b5877570a634d4a6 /test/CodeGenCoroutines
parent7ee1354f0554cf8a9a20b6bf035366bd959efc1b (diff)
[coroutines] Fix building of new/delete expressions when get_return_object_on_allocation_failure() is present.
Summary: This patch implements [dcl.fct.def.coroutine]p8: > The unqualified-id get_return_object_on_allocation_failure is looked up in the scope of > class P by class member access lookup (3.4.5). If a declaration is found, ..., and if a > global allocation function is selected, the ::operator new(size_t, nothrow_t) form shall be used. > [...] > The allocation function used in this case must have a non-throwing noexcept-specification. Reviewers: GorNishanov, rsmith, majnemer, aaron.ballman Reviewed By: GorNishanov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D31562 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300524 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCoroutines')
-rw-r--r--test/CodeGenCoroutines/coro-alloc.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/test/CodeGenCoroutines/coro-alloc.cpp b/test/CodeGenCoroutines/coro-alloc.cpp
index 7ff57faeaf..3a65736f6c 100644
--- a/test/CodeGenCoroutines/coro-alloc.cpp
+++ b/test/CodeGenCoroutines/coro-alloc.cpp
@@ -21,8 +21,19 @@ struct coroutine_handle<void> {
coroutine_handle(coroutine_handle<PromiseType>) {}
};
-}
-}
+} // end namespace experimental
+
+struct nothrow_t {};
+constexpr nothrow_t nothrow = {};
+
+} // end namespace std
+
+// Required when get_return_object_on_allocation_failure() is defined by
+// the promise.
+using SizeT = decltype(sizeof(int));
+void* operator new(SizeT __sz, const std::nothrow_t&) noexcept;
+void operator delete(void* __p, const std::nothrow_t&) noexcept;
+
struct suspend_always {
bool await_ready() { return false; }
@@ -147,7 +158,7 @@ struct std::experimental::coroutine_traits<int, promise_on_alloc_failure_tag> {
extern "C" int f4(promise_on_alloc_failure_tag) {
// CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16
// CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
- // CHECK: %[[MEM:.+]] = call i8* @_Znwm(i64 %[[SIZE]])
+ // CHECK: %[[MEM:.+]] = call i8* @_ZnwmRKSt9nothrow_t(i64 %[[SIZE]], %"struct.std::nothrow_t"* dereferenceable(1) @_ZStL7nothrow)
// CHECK: %[[OK:.+]] = icmp ne i8* %[[MEM]], null
// CHECK: br i1 %[[OK]], label %[[OKBB:.+]], label %[[ERRBB:.+]]