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

@@ -171,4 +171,91 @@ public:
} // std
_LIBCPP_BEGIN_NAMESPACE_STD
// in the dylib
_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_runtime_error(const char*);
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_logic_error(const char*__msg)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw logic_error(__msg);
#else
_VSTD::abort();
#endif
}
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_domain_error(const char*__msg)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw domain_error(__msg);
#else
_VSTD::abort();
#endif
}
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_invalid_argument(const char*__msg)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw invalid_argument(__msg);
#else
_VSTD::abort();
#endif
}
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_length_error(const char*__msg)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw length_error(__msg);
#else
_VSTD::abort();
#endif
}
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_out_of_range(const char*__msg)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw out_of_range(__msg);
#else
_VSTD::abort();
#endif
}
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_range_error(const char*__msg)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw range_error(__msg);
#else
_VSTD::abort();
#endif
}
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_overflow_error(const char*__msg)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw overflow_error(__msg);
#else
_VSTD::abort();
#endif
}
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_underflow_error(const char*__msg)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw underflow_error(__msg);
#else
_VSTD::abort();
#endif
}
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_STDEXCEPT