Add an _LIBCPP_NORETURN inline function named __throw_XXX for each exception type we define. They either construct and throw the exception, or abort() (if exceptions are disabled). Use these functions everywhere instead of assert()ing when exceptions are disabled. WARNING: This is a behavior change - but only with exceptions disabled. Reviewed as: https://reviews.llvm.org/D23855.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@279744 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -637,9 +637,6 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
|
||||
#include <tuple>
|
||||
#include <stdexcept>
|
||||
#include <cstring>
|
||||
#if defined(_LIBCPP_NO_EXCEPTIONS)
|
||||
#include <cassert>
|
||||
#endif
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
|
||||
# include <atomic>
|
||||
@@ -3787,6 +3784,16 @@ public:
|
||||
virtual const char* what() const _NOEXCEPT;
|
||||
};
|
||||
|
||||
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
|
||||
void __throw_bad_weak_ptr()
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
throw bad_weak_ptr();
|
||||
#else
|
||||
_VSTD::abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY weak_ptr;
|
||||
|
||||
class _LIBCPP_TYPE_VIS __shared_count
|
||||
@@ -5443,11 +5450,7 @@ shared_ptr<_Tp>::shared_ptr(const weak_ptr<_Yp>& __r,
|
||||
__cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_)
|
||||
{
|
||||
if (__cntrl_ == 0)
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
throw bad_weak_ptr();
|
||||
#else
|
||||
assert(!"bad_weak_ptr");
|
||||
#endif
|
||||
__throw_bad_weak_ptr();
|
||||
}
|
||||
|
||||
template<class _Tp>
|
||||
|
||||
Reference in New Issue
Block a user