diff options
| author | Eric Fiselier <eric@efcs.ca> | 2017-02-10 04:25:33 +0000 |
|---|---|---|
| committer | Eric Fiselier <eric@efcs.ca> | 2017-02-10 04:25:33 +0000 |
| commit | def60acdf5ff7d5c8807bcf5382de2767e3a8819 (patch) | |
| tree | 951b04a74001095c5c7f51255873fba8ff705ceb /libcxx/src/support/runtime/exception_pointer_cxxabi.ipp | |
| parent | 982c5eb396a9a30b5dd17ac71fab9a9860317e85 (diff) | |
| download | bcm5719-llvm-def60acdf5ff7d5c8807bcf5382de2767e3a8819.tar.gz bcm5719-llvm-def60acdf5ff7d5c8807bcf5382de2767e3a8819.zip | |
Split exception.cpp and new.cpp implementation into different files for different runtimes.
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: 294707
Diffstat (limited to 'libcxx/src/support/runtime/exception_pointer_cxxabi.ipp')
| -rw-r--r-- | libcxx/src/support/runtime/exception_pointer_cxxabi.ipp | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp new file mode 100644 index 00000000000..dfac8648c49 --- /dev/null +++ b/libcxx/src/support/runtime/exception_pointer_cxxabi.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. +// +//===----------------------------------------------------------------------===// + +#ifndef HAVE_DEPENDENT_EH_ABI +#error this header may only be used with libc++abi or libcxxrt +#endif + +namespace std { + +exception_ptr::~exception_ptr() _NOEXCEPT { + __cxa_decrement_exception_refcount(__ptr_); +} + +exception_ptr::exception_ptr(const exception_ptr& other) _NOEXCEPT + : __ptr_(other.__ptr_) +{ + __cxa_increment_exception_refcount(__ptr_); +} + +exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT +{ + if (__ptr_ != other.__ptr_) + { + __cxa_increment_exception_refcount(other.__ptr_); + __cxa_decrement_exception_refcount(__ptr_); + __ptr_ = other.__ptr_; + } + return *this; +} + +nested_exception::nested_exception() _NOEXCEPT + : __ptr_(current_exception()) +{ +} + +nested_exception::~nested_exception() _NOEXCEPT +{ +} + +_LIBCPP_NORETURN +void +nested_exception::rethrow_nested() const +{ + if (__ptr_ == nullptr) + terminate(); + rethrow_exception(__ptr_); +} + +exception_ptr current_exception() _NOEXCEPT +{ + // be nicer if there was a constructor that took a ptr, then + // this whole function would be just: + // return exception_ptr(__cxa_current_primary_exception()); + exception_ptr ptr; + ptr.__ptr_ = __cxa_current_primary_exception(); + return ptr; +} + +_LIBCPP_NORETURN +void rethrow_exception(exception_ptr p) +{ + __cxa_rethrow_primary_exception(p.__ptr_); + // if p.__ptr_ is NULL, above returns so we terminate + terminate(); +} + +} // namespace std |

