summaryrefslogtreecommitdiff
path: root/test/CodeGenCoroutines
diff options
context:
space:
mode:
authorGor Nishanov <GorNishanov@gmail.com>2017-03-09 03:09:43 +0000
committerGor Nishanov <GorNishanov@gmail.com>2017-03-09 03:09:43 +0000
commit48672a5fa2f8a4fe6e4273e6e496e5fa17182c9e (patch)
tree2aaaa4a9490ee0a606e88c70596bd5960dd659aa /test/CodeGenCoroutines
parent051c5018aa747eee15a2f646dd5dab4aba93b7f3 (diff)
[coroutines] Build and pass coroutine_handle to await_suspend
Summary: This patch adds passing a coroutine_handle object to await_suspend calls. It builds the coroutine_handle using coroutine_handle<PromiseType>::from_address(__builtin_coro_frame()). (a revision of https://reviews.llvm.org/D26316 that for some reason refuses to apply via arc patch) Reviewers: GorNishanov Subscribers: mehdi_amini, cfe-commits, EricWF Differential Revision: https://reviews.llvm.org/D30769 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@297356 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCoroutines')
-rw-r--r--test/CodeGenCoroutines/coro-alloc.cpp17
-rw-r--r--test/CodeGenCoroutines/coro-return.cpp17
2 files changed, 32 insertions, 2 deletions
diff --git a/test/CodeGenCoroutines/coro-alloc.cpp b/test/CodeGenCoroutines/coro-alloc.cpp
index 87da7aed89..c795e27326 100644
--- a/test/CodeGenCoroutines/coro-alloc.cpp
+++ b/test/CodeGenCoroutines/coro-alloc.cpp
@@ -4,12 +4,27 @@ namespace std {
namespace experimental {
template <typename... T>
struct coroutine_traits; // expected-note {{declared here}}
+
+template <class Promise = void>
+struct coroutine_handle {
+ coroutine_handle() = default;
+ static coroutine_handle from_address(void *) { return {}; }
+};
+
+template <>
+struct coroutine_handle<void> {
+ static coroutine_handle from_address(void *) { return {}; }
+ coroutine_handle() = default;
+ template <class PromiseType>
+ coroutine_handle(coroutine_handle<PromiseType>) {}
+};
+
}
}
struct suspend_always {
bool await_ready() { return false; }
- void await_suspend() {}
+ void await_suspend(std::experimental::coroutine_handle<>) {}
void await_resume() {}
};
diff --git a/test/CodeGenCoroutines/coro-return.cpp b/test/CodeGenCoroutines/coro-return.cpp
index 2b94da8336..26aaa90077 100644
--- a/test/CodeGenCoroutines/coro-return.cpp
+++ b/test/CodeGenCoroutines/coro-return.cpp
@@ -4,12 +4,27 @@ namespace std {
namespace experimental {
template <typename... T>
struct coroutine_traits;
+
+template <class Promise = void>
+struct coroutine_handle {
+ coroutine_handle() = default;
+ static coroutine_handle from_address(void *) { return {}; }
+};
+
+template <>
+struct coroutine_handle<void> {
+ static coroutine_handle from_address(void *) { return {}; }
+ coroutine_handle() = default;
+ template <class PromiseType>
+ coroutine_handle(coroutine_handle<PromiseType>) {}
+};
+
}
}
struct suspend_always {
bool await_ready();
- void await_suspend();
+ void await_suspend(std::experimental::coroutine_handle<>);
void await_resume();
};