summaryrefslogtreecommitdiffstats
path: root/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2017-02-10 08:57:35 +0000
committerEric Fiselier <eric@efcs.ca>2017-02-10 08:57:35 +0000
commitd22c9dc4222bb875be4efb496396b8b449a09e57 (patch)
tree611813b10b6d06f96d472103dcb4c277eeda9ade /libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
parent7bc6028d7d53351f7131e7d4f2f9bfc2ee2679b7 (diff)
downloadbcm5719-llvm-d22c9dc4222bb875be4efb496396b8b449a09e57.tar.gz
bcm5719-llvm-d22c9dc4222bb875be4efb496396b8b449a09e57.zip
Recommit "Split exception.cpp and new.cpp implementation into different files for different runtimes."
This recommits r294707 with additional fixes. The main difference is libc++ now correctly builds without any ABI library. exception.cpp is a bloody mess. It's full of confusing #ifdef branches for each different ABI library we support, and it's getting unmaintainable. This patch breaks down exception.cpp into multiple different header files, roughly one per implementation. Additionally it moves the definitions of exceptions in new.cpp into the correct implementation header. This patch also removes an unmaintained libc++abi configuration. This configuration may still be used by Apple internally but there are no other possible users. If it turns out that Apple still uses this configuration internally I will re-add it in a later commit. See http://llvm.org/PR31904. llvm-svn: 294730
Diffstat (limited to 'libcxx/src/support/runtime/exception_pointer_glibcxx.ipp')
-rw-r--r--libcxx/src/support/runtime/exception_pointer_glibcxx.ipp74
1 files changed, 74 insertions, 0 deletions
diff --git a/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp b/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
new file mode 100644
index 00000000000..30bd6b61f08
--- /dev/null
+++ b/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
@@ -0,0 +1,74 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// libsupc++ does not implement the dependent EH ABI and the functionality
+// it uses to implement std::exception_ptr (which it declares as an alias of
+// std::__exception_ptr::exception_ptr) is not directly exported to clients. So
+// we have little choice but to hijack std::__exception_ptr::exception_ptr's
+// (which fortunately has the same layout as our std::exception_ptr) copy
+// constructor, assignment operator and destructor (which are part of its
+// stable ABI), and its rethrow_exception(std::__exception_ptr::exception_ptr)
+// function.
+
+namespace __exception_ptr
+{
+
+struct exception_ptr
+{
+ void* __ptr_;
+
+ exception_ptr(const exception_ptr&) _NOEXCEPT;
+ exception_ptr& operator=(const exception_ptr&) _NOEXCEPT;
+ ~exception_ptr() _NOEXCEPT;
+};
+
+}
+
+_LIBCPP_NORETURN void rethrow_exception(__exception_ptr::exception_ptr);
+
+exception_ptr::~exception_ptr() _NOEXCEPT
+{
+ reinterpret_cast<__exception_ptr::exception_ptr*>(this)->~exception_ptr();
+}
+
+exception_ptr::exception_ptr(const exception_ptr& other) _NOEXCEPT
+ : __ptr_(other.__ptr_)
+{
+ new (reinterpret_cast<void*>(this)) __exception_ptr::exception_ptr(
+ reinterpret_cast<const __exception_ptr::exception_ptr&>(other));
+}
+
+exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT
+{
+ *reinterpret_cast<__exception_ptr::exception_ptr*>(this) =
+ reinterpret_cast<const __exception_ptr::exception_ptr&>(other);
+ return *this;
+}
+
+nested_exception::nested_exception() _NOEXCEPT
+ : __ptr_(current_exception())
+{
+}
+
+
+_LIBCPP_NORETURN
+void
+nested_exception::rethrow_nested() const
+{
+ if (__ptr_ == nullptr)
+ terminate();
+ rethrow_exception(__ptr_);
+}
+
+_LIBCPP_NORETURN
+void rethrow_exception(exception_ptr p)
+{
+ rethrow_exception(reinterpret_cast<__exception_ptr::exception_ptr&>(p));
+}
OpenPOWER on IntegriCloud