summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCoroutines
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2017-04-17 22:06:13 +0000
committerEric Fiselier <eric@efcs.ca>2017-04-17 22:06:13 +0000
commit1772bdb2438378c9da3ce2eff55c81f1804d6df1 (patch)
tree898a567fe905a7802f12f2d3ea0d721dbe936e64 /test/CodeGenCoroutines
parent71f194f12dc686d5a39e9f94cdfbae8984eadbae (diff)
[coroutines] Fix rebuilding of implicit and dependent coroutine statements.
Summary: Certain implicitly generated coroutine statements, such as the calls to 'return_value()' or `return_void()` or `get_return_object_on_allocation_failure()`, cannot be built until the promise type is no longer dependent. This means they are not built until after the coroutine body statement has been transformed. This patch fixes an issue where these statements would never be built for coroutine templates. It also fixes a small issue where diagnostics about `get_return_object_on_allocation_failure()` were incorrectly suppressed. Reviewers: rsmith, majnemer, GorNishanov, aaron.ballman Reviewed By: GorNishanov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D31487 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300504 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 f0a600eabe..003095498b 100644
--- a/test/CodeGenCoroutines/coro-alloc.cpp
+++ b/test/CodeGenCoroutines/coro-alloc.cpp
@@ -19,8 +19,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; }
@@ -145,7 +156,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:.+]]