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:
Marshall Clow
2016-08-25 15:09:01 +00:00
parent fdb4f1713e
commit 14c09a2413
30 changed files with 272 additions and 288 deletions

View File

@@ -1382,6 +1382,16 @@ class _LIBCPP_EXCEPTION_ABI bad_function_call
{
};
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_bad_function_call()
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw bad_function_call();
#else
_VSTD::abort();
#endif
}
template<class _Fp> class _LIBCPP_TYPE_VIS_ONLY function; // undefined
namespace __function
@@ -1882,10 +1892,8 @@ template<class _Rp, class ..._ArgTypes>
_Rp
function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const
{
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__f_ == 0)
throw bad_function_call();
#endif // _LIBCPP_NO_EXCEPTIONS
__throw_bad_function_call();
return (*__f_)(_VSTD::forward<_ArgTypes>(__arg)...);
}