mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-23 10:07:41 +08:00
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:
@@ -106,10 +106,6 @@ public:
|
||||
|
||||
#include <__undef___deallocate>
|
||||
|
||||
#if defined(_LIBCPP_NO_EXCEPTIONS)
|
||||
#include <cassert>
|
||||
#endif
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
@@ -142,13 +138,8 @@ private:
|
||||
static inline _LIBCPP_INLINE_VISIBILITY value_type* __allocate ( size_t count )
|
||||
{
|
||||
if ( numeric_limits<size_t>::max() / sizeof (value_type) <= count )
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
throw bad_array_length();
|
||||
#else
|
||||
assert(!"dynarray::allocation");
|
||||
#endif
|
||||
}
|
||||
__throw_bad_array_length();
|
||||
|
||||
return static_cast<value_type *> (_VSTD::__allocate (sizeof(value_type) * count));
|
||||
}
|
||||
|
||||
@@ -283,13 +274,8 @@ typename dynarray<_Tp>::reference
|
||||
dynarray<_Tp>::at(size_type __n)
|
||||
{
|
||||
if (__n >= __size_)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
throw out_of_range("dynarray::at");
|
||||
#else
|
||||
assert(!"dynarray::at out_of_range");
|
||||
#endif
|
||||
}
|
||||
__throw_out_of_range("dynarray::at");
|
||||
|
||||
return data()[__n];
|
||||
}
|
||||
|
||||
@@ -299,13 +285,8 @@ typename dynarray<_Tp>::const_reference
|
||||
dynarray<_Tp>::at(size_type __n) const
|
||||
{
|
||||
if (__n >= __size_)
|
||||
{
|
||||
#ifndef _LIBCPP_NO_EXCEPTIONS
|
||||
throw out_of_range("dynarray::at");
|
||||
#else
|
||||
assert(!"dynarray::at out_of_range");
|
||||
#endif
|
||||
}
|
||||
__throw_out_of_range("dynarray::at");
|
||||
|
||||
return data()[__n];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user