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

@@ -477,10 +477,6 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++1
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
#include <cstdint>
#endif
#if defined(_LIBCPP_NO_EXCEPTIONS)
#include <cassert>
#endif
#include <__undef_min_max>
@@ -556,30 +552,22 @@ template <bool>
class _LIBCPP_TYPE_VIS_ONLY __basic_string_common
{
protected:
void __throw_length_error() const;
void __throw_out_of_range() const;
_LIBCPP_NORETURN void __throw_length_error() const;
_LIBCPP_NORETURN void __throw_out_of_range() const;
};
template <bool __b>
void
__basic_string_common<__b>::__throw_length_error() const
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw length_error("basic_string");
#else
assert(!"basic_string length_error");
#endif
_VSTD::__throw_length_error("basic_string");
}
template <bool __b>
void
__basic_string_common<__b>::__throw_out_of_range() const
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw out_of_range("basic_string");
#else
assert(!"basic_string out_of_range");
#endif
_VSTD::__throw_out_of_range("basic_string");
}
#ifdef _LIBCPP_MSVC