-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[coroutines] Wrap the body of the coroutine in try-catch
Summary: If unhandled_exception member function is present in the coroutine promise, wrap the body of the coroutine in: ``` try { body } catch(...) { promise.unhandled_exception(); } ``` Reviewers: EricWF, rnk, rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D31692 llvm-svn: 303583
- Loading branch information
1 parent
eb00ee0
commit 5b050e4
Showing
6 changed files
with
125 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// RUN: %clang_cc1 -std=c++1z -fcoroutines-ts -verify %s -fcxx-exceptions -fexceptions -triple x86_64-windows-msvc -fms-extensions | ||
namespace std::experimental { | ||
template <typename... T> struct coroutine_traits; | ||
|
||
template <class Promise = void> struct coroutine_handle { | ||
coroutine_handle() = default; | ||
static coroutine_handle from_address(void *) noexcept; | ||
}; | ||
template <> struct coroutine_handle<void> { | ||
static coroutine_handle from_address(void *) noexcept; | ||
coroutine_handle() = default; | ||
template <class PromiseType> | ||
coroutine_handle(coroutine_handle<PromiseType>) noexcept; | ||
}; | ||
} | ||
|
||
struct suspend_always { | ||
bool await_ready() noexcept; | ||
void await_suspend(std::experimental::coroutine_handle<>) noexcept; | ||
void await_resume() noexcept; | ||
}; | ||
|
||
template <> struct std::experimental::coroutine_traits<void> { | ||
struct promise_type { | ||
void get_return_object() noexcept; | ||
suspend_always initial_suspend() noexcept; | ||
suspend_always final_suspend() noexcept; | ||
void return_void() noexcept; | ||
void unhandled_exception() noexcept; | ||
}; | ||
}; | ||
|
||
void SEH_used() { | ||
__try { // expected-error {{cannot use SEH '__try' in a coroutine when C++ exceptions are enabled}} | ||
co_return; // expected-note {{function is a coroutine due to use of 'co_return' here}} | ||
} __except(0) {} | ||
} |