2 //===----------------------------------------------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 // libsupc++ does not implement the dependent EH ABI and the functionality
12 // it uses to implement std::exception_ptr (which it declares as an alias of
13 // std::__exception_ptr::exception_ptr) is not directly exported to clients. So
14 // we have little choice but to hijack std::__exception_ptr::exception_ptr's
15 // (which fortunately has the same layout as our std::exception_ptr) copy
16 // constructor, assignment operator and destructor (which are part of its
17 // stable ABI), and its rethrow_exception(std::__exception_ptr::exception_ptr)
22 namespace __exception_ptr
29 exception_ptr(const exception_ptr&) _NOEXCEPT;
30 exception_ptr& operator=(const exception_ptr&) _NOEXCEPT;
31 ~exception_ptr() _NOEXCEPT;
36 _LIBCPP_NORETURN void rethrow_exception(__exception_ptr::exception_ptr);
38 exception_ptr::~exception_ptr() _NOEXCEPT
40 reinterpret_cast<__exception_ptr::exception_ptr*>(this)->~exception_ptr();
43 exception_ptr::exception_ptr(const exception_ptr& other) _NOEXCEPT
44 : __ptr_(other.__ptr_)
46 new (reinterpret_cast<void*>(this)) __exception_ptr::exception_ptr(
47 reinterpret_cast<const __exception_ptr::exception_ptr&>(other));
50 exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT
52 *reinterpret_cast<__exception_ptr::exception_ptr*>(this) =
53 reinterpret_cast<const __exception_ptr::exception_ptr&>(other);
57 nested_exception::nested_exception() _NOEXCEPT
58 : __ptr_(current_exception())
65 nested_exception::rethrow_nested() const
67 if (__ptr_ == nullptr)
69 rethrow_exception(__ptr_);
73 void rethrow_exception(exception_ptr p)
75 rethrow_exception(reinterpret_cast<__exception_ptr::exception_ptr&>(p));