Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions libcxx/src/exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,12 @@
#define _LIBCPP_ENABLE_CXX20_REMOVED_UNCAUGHT_EXCEPTION
#define _LIBCPP_DISABLE_DEPRECATION_WARNINGS

#include <exception>
#include <new>
#include <typeinfo>

#if defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI)
# include <cxxabi.h>
using namespace __cxxabiv1;
# define HAVE_DEPENDENT_EH_ABI 1
#endif
#include <__config>

#if defined(_LIBCPP_ABI_MICROSOFT)
# include "support/runtime/exception_msvc.ipp"
# include "support/runtime/exception_pointer_msvc.ipp"
#elif defined(_LIBCPPABI_VERSION)
#elif defined(LIBCXX_BUILDING_LIBCXXABI)
# include "support/runtime/exception_libcxxabi.ipp"
# include "support/runtime/exception_pointer_cxxabi.ipp"
#elif defined(LIBCXXRT)
Expand Down
2 changes: 2 additions & 0 deletions libcxx/src/support/runtime/exception_fallback.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
//===----------------------------------------------------------------------===//

#include <__verbose_abort>
#include <exception>
#include "include/atomic_support.h"

namespace std {

Expand Down
3 changes: 3 additions & 0 deletions libcxx/src/support/runtime/exception_glibcxx.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
# error header can only be used when targeting libstdc++ or libsupc++
#endif

#include <exception>
#include <new>

namespace std {

bad_alloc::bad_alloc() noexcept {}
Expand Down
8 changes: 6 additions & 2 deletions libcxx/src/support/runtime/exception_libcxxabi.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//

#include <exception>

#include <cxxabi.h>

#ifndef _LIBCPPABI_VERSION
# error this header can only be used with libc++abi
#endif
Expand All @@ -17,9 +21,9 @@ bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; }

int uncaught_exceptions() noexcept {
#if _LIBCPPABI_VERSION > 1001
return __cxa_uncaught_exceptions();
return abi::__cxa_uncaught_exceptions();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this abi:: namespace? I can't find where it's defined.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an alias to __cxxabiv1 and it's defined in cxxabi.h.

#else
return __cxa_uncaught_exception() ? 1 : 0;
return abi::__cxa_uncaught_exception() ? 1 : 0;
#endif
}

Expand Down
2 changes: 2 additions & 0 deletions libcxx/src/support/runtime/exception_libcxxrt.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# error this header may only be used when targeting libcxxrt
#endif

#include <exception>

namespace std {

bad_exception::~bad_exception() noexcept {}
Expand Down
2 changes: 2 additions & 0 deletions libcxx/src/support/runtime/exception_msvc.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#endif

#include <__verbose_abort>
#include <exception>
#include <new>

extern "C" {
typedef void(__cdecl* terminate_handler)();
Expand Down
19 changes: 9 additions & 10 deletions libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,21 @@
//
//===----------------------------------------------------------------------===//

#ifndef HAVE_DEPENDENT_EH_ABI
# error this header may only be used with libc++abi or libcxxrt
#endif
#include <cxxabi.h>
#include <exception>

namespace std {

exception_ptr::~exception_ptr() noexcept { __cxa_decrement_exception_refcount(__ptr_); }
exception_ptr::~exception_ptr() noexcept { abi::__cxa_decrement_exception_refcount(__ptr_); }

exception_ptr::exception_ptr(const exception_ptr& other) noexcept : __ptr_(other.__ptr_) {
__cxa_increment_exception_refcount(__ptr_);
abi::__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_);
abi::__cxa_increment_exception_refcount(other.__ptr_);
abi::__cxa_decrement_exception_refcount(__ptr_);
__ptr_ = other.__ptr_;
}
return *this;
Expand All @@ -31,7 +30,7 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept {
exception_ptr exception_ptr::__from_native_exception_pointer(void* __e) noexcept {
exception_ptr ptr;
ptr.__ptr_ = __e;
__cxa_increment_exception_refcount(ptr.__ptr_);
abi::__cxa_increment_exception_refcount(ptr.__ptr_);

return ptr;
}
Expand All @@ -51,12 +50,12 @@ exception_ptr current_exception() noexcept {
// this whole function would be just:
// return exception_ptr(__cxa_current_primary_exception());
exception_ptr ptr;
ptr.__ptr_ = __cxa_current_primary_exception();
ptr.__ptr_ = abi::__cxa_current_primary_exception();
return ptr;
}

void rethrow_exception(exception_ptr p) {
__cxa_rethrow_primary_exception(p.__ptr_);
abi::__cxa_rethrow_primary_exception(p.__ptr_);
// if p.__ptr_ is NULL, above returns so we terminate
terminate();
}
Expand Down
2 changes: 2 additions & 0 deletions libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
// stable ABI), and its rethrow_exception(std::__exception_ptr::exception_ptr)
// function.

#include <exception>

namespace std {

namespace __exception_ptr {
Expand Down
1 change: 1 addition & 0 deletions libcxx/src/support/runtime/exception_pointer_msvc.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//

#include <exception>
#include <stdio.h>
#include <stdlib.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//

#include <__verbose_abort>
#include <exception>

namespace std {

Expand Down
Loading