-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[libc++] Add move constructor & assignment to exception_ptr
#164281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 15 commits
5527b28
36757da
740129e
8d90812
b106dc9
1a26712
baba555
2a22036
fb3c655
ee4694c
3c910b8
510786c
20bcce5
8a1a9cf
32a85dd
268fbcf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ export namespace std { | |
| using std::rethrow_exception; | ||
| using std::rethrow_if_nested; | ||
| using std::set_terminate; | ||
| using std::swap; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to add I don't quite understand the modules build, though. Is this correct? (Note that we now have both a
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't quite understand how these tests work either. I'm happy if the CI is happy here.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The CI was indeed green 🙂 |
||
| using std::terminate; | ||
| using std::terminate_handler; | ||
| using std::throw_with_nested; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,6 @@ | |
|
|
||
| #include <exception> | ||
| #include <cassert> | ||
| #include <type_traits> | ||
|
|
||
| #include "test_macros.h" | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
vogelsgesang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // UNSUPPORTED: no-exceptions, c++03 | ||
|
|
||
| // <exception> | ||
|
|
||
| // typedef unspecified exception_ptr; | ||
|
|
||
| // Test the move assignment of exception_ptr | ||
|
|
||
| #include <exception> | ||
| #include <utility> | ||
| #include <cassert> | ||
|
|
||
| #include "test_macros.h" | ||
|
|
||
| int main(int, char**) { | ||
| std::exception_ptr p = std::make_exception_ptr(42); | ||
| std::exception_ptr p2{p}; | ||
| assert(p2 == p); | ||
| // Under test: the move assignment | ||
| std::exception_ptr p3; | ||
| p3 = std::move(p2); | ||
| assert(p3 == p); | ||
| // `p2` was moved from. In libc++ it will be nullptr, but | ||
| // this is not guaranteed by the standard. | ||
| #if defined(_LIBCPP_VERSION) && !defined(_LIBCPP_ABI_MICROSOFT) | ||
| assert(p2 == nullptr); | ||
| assert(p2 == nullptr); | ||
| #endif | ||
|
|
||
| try { | ||
| std::rethrow_exception(p3); | ||
| } catch (int e) { | ||
| assert(e == 42); | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // UNSUPPORTED: no-exceptions, c++03 | ||
|
|
||
| // <exception> | ||
|
|
||
| // typedef unspecified exception_ptr; | ||
|
|
||
| // Test the move constructor of exception_ptr | ||
|
|
||
| #include <exception> | ||
| #include <utility> | ||
| #include <cassert> | ||
|
|
||
| #include "test_macros.h" | ||
|
|
||
| int main(int, char**) { | ||
| std::exception_ptr p = std::make_exception_ptr(42); | ||
| std::exception_ptr p2{p}; | ||
| assert(p2 == p); | ||
| // Under test: The move constructor | ||
| std::exception_ptr p3{std::move(p2)}; | ||
| assert(p3 == p); | ||
| // `p2` was moved from. In libc++ it will be nullptr, but | ||
| // this is not guaranteed by the standard. | ||
| #if defined(_LIBCPP_VERSION) && !defined(_LIBCPP_ABI_MICROSOFT) | ||
| assert(p2 == nullptr); | ||
| #endif | ||
|
|
||
| try { | ||
| std::rethrow_exception(p3); | ||
| } catch (int e) { | ||
| assert(e == 42); | ||
| } | ||
|
|
||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| // UNSUPPORTED: no-exceptions | ||
|
|
||
| // <exception> | ||
|
|
||
| // typedef unspecified exception_ptr; | ||
|
|
||
| // Test swapping of exception_ptr | ||
|
|
||
| #include <exception> | ||
| #include <utility> | ||
| #include <cassert> | ||
|
|
||
| #include "test_macros.h" | ||
|
|
||
| int main(int, char**) { | ||
| std::exception_ptr p21 = std::make_exception_ptr(42); | ||
| std::exception_ptr p42 = std::make_exception_ptr(21); | ||
| std::swap(p42, p21); | ||
|
|
||
| try { | ||
| std::rethrow_exception(p21); | ||
| } catch (int e) { | ||
| assert(e == 21); | ||
| } | ||
| try { | ||
| std::rethrow_exception(p42); | ||
| } catch (int e) { | ||
| assert(e == 42); | ||
| } | ||
|
|
||
| return 0; | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.