diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2016-08-25 15:09:01 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2016-08-25 15:09:01 +0000 |
commit | 14c09a2413ed5cc4914d1690f5dbfb9420a45b3c (patch) | |
tree | 8f7149218fefcbce3abf3ec60f3d31c126d9f63d /include/memory | |
parent | fdb4f1713ece3c6f7fbf98f3ea3f8c19fa0c249e (diff) |
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
Diffstat (limited to 'include/memory')
-rw-r--r-- | include/memory | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/include/memory b/include/memory index 5cdb60f5e..7047bc717 100644 --- a/include/memory +++ b/include/memory @@ -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> |