Followon to r279744. Find the other exception types and make __throw_XXX routines (and call them). Remove the generic __libcpp_throw routine, since no one uses it anymore.

llvm-svn: 279763
This commit is contained in:
Marshall Clow 2016-08-25 17:47:09 +00:00
parent 6c43b850b7
commit 0fc8cec796
9 changed files with 40 additions and 34 deletions

View File

@ -102,6 +102,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER > 14
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_bad_any_cast()
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw bad_any_cast();
#else
_VSTD::abort();
#endif
}
// Forward declarations
class _LIBCPP_TYPE_VIS_ONLY any;
@ -579,7 +589,7 @@ _ValueType any_cast(any const & __v)
using _Tp = add_const_t<remove_reference_t<_ValueType>>;
_Tp * __tmp = _VSTD::any_cast<_Tp>(&__v);
if (__tmp == nullptr)
__libcpp_throw(bad_any_cast());
__throw_bad_any_cast();
return *__tmp;
}
@ -594,7 +604,7 @@ _ValueType any_cast(any & __v)
typedef typename remove_reference<_ValueType>::type _Tp;
_Tp * __tmp = _VSTD::any_cast<_Tp>(&__v);
if (__tmp == nullptr)
__libcpp_throw(bad_any_cast());
__throw_bad_any_cast();
return *__tmp;
}
@ -614,7 +624,7 @@ _ValueType any_cast(any && __v)
>;
_Tp * __tmp = _VSTD::any_cast<_Tp>(&__v);
if (__tmp == nullptr)
__libcpp_throw(bad_any_cast());
__throw_bad_any_cast();
return _VSTD::forward<_ForwardTp>(*__tmp);
}

View File

@ -255,19 +255,4 @@ rethrow_if_nested(const _Ep&, typename enable_if<
} // std
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Exception>
_LIBCPP_INLINE_VISIBILITY
inline void __libcpp_throw(_Exception const& __e) {
#ifndef _LIBCPP_NO_EXCEPTIONS
throw __e;
#else
_VSTD::fprintf(stderr, "%s\n", __e.what());
_VSTD::abort();
#endif
}
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_EXCEPTION

View File

@ -1176,6 +1176,17 @@ private:
shared_ptr<_Storage> __paths_;
};
template <class... _Args>
_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
void __throw_filesystem_error(_Args && ...__args)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
throw filesystem_error(std::forward<_Args>(__args)...);
#else
_VSTD::abort();
#endif
}
// operational functions
_LIBCPP_FUNC_VIS

View File

@ -182,9 +182,9 @@ public:
_LIBCPP_INLINE_VISIBILITY
_ValueType* allocate(size_t __n) {
if (__n > max_size()) {
__libcpp_throw(length_error(
__throw_length_error(
"std::experimental::pmr::polymorphic_allocator<T>::allocate(size_t n)"
" 'n' exceeds maximum supported size"));
" 'n' exceeds maximum supported size");
}
return static_cast<_ValueType*>(
__res_->allocate(__n * sizeof(_ValueType), alignof(_ValueType))
@ -383,9 +383,9 @@ protected:
virtual void * do_allocate(size_t __bytes, size_t)
{
if (__bytes > __max_size()) {
__libcpp_throw(length_error(
__throw_length_error(
"std::experimental::pmr::resource_adaptor<T>::do_allocate(size_t bytes, size_t align)"
" 'bytes' exceeds maximum supported size"));
" 'bytes' exceeds maximum supported size");
}
size_t __s = __aligned_allocation_size(__bytes, _MaxAlign) / _MaxAlign;
return __alloc_.allocate(__s);

View File

@ -281,7 +281,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
const_reference at(size_type __pos) const
{
return __pos >= size()
? (__libcpp_throw(out_of_range("string_view::at")), __data[0])
? (__throw_out_of_range("string_view::at"), __data[0])
: __data[__pos];
}
@ -352,7 +352,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
{
if ( __pos > size())
__libcpp_throw(out_of_range("string_view::copy"));
__throw_out_of_range("string_view::copy");
size_type __rlen = _VSTD::min( __n, size() - __pos );
_VSTD::copy_n(begin() + __pos, __rlen, __s );
return __rlen;

View File

@ -1754,8 +1754,8 @@ public:
_LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0)
{
if (__n > max_size())
__libcpp_throw(length_error("allocator<T>::allocate(size_t n)"
" 'n' exceeds maximum supported size"));
__throw_length_error("allocator<T>::allocate(size_t n)"
" 'n' exceeds maximum supported size");
return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));
}
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT
@ -1850,8 +1850,8 @@ public:
_LIBCPP_INLINE_VISIBILITY pointer allocate(size_type __n, allocator<void>::const_pointer = 0)
{
if (__n > max_size())
__libcpp_throw(length_error("allocator<const T>::allocate(size_t n)"
" 'n' exceeds maximum supported size"));
__throw_length_error("allocator<const T>::allocate(size_t n)"
" 'n' exceeds maximum supported size");
return static_cast<pointer>(_VSTD::__allocate(__n * sizeof(_Tp)));
}
_LIBCPP_INLINE_VISIBILITY void deallocate(pointer __p, size_type) _NOEXCEPT

View File

@ -261,7 +261,7 @@ public:
const_reference at(size_type __pos) const
{
return __pos >= size()
? (__libcpp_throw(out_of_range("string_view::at")), __data[0])
? (__throw_out_of_range("string_view::at"), __data[0])
: __data[__pos];
}
@ -319,7 +319,7 @@ public:
size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
{
if (__pos > size())
__libcpp_throw(out_of_range("string_view::copy"));
__throw_out_of_range("string_view::copy");
size_type __rlen = _VSTD::min( __n, size() - __pos );
copy_n(begin() + __pos, __rlen, __s );
return __rlen;
@ -329,7 +329,7 @@ public:
basic_string_view substr(size_type __pos = 0, size_type __n = npos) const
{
return __pos > size()
? (__libcpp_throw((out_of_range("string_view::substr"))), basic_string_view())
? (__throw_out_of_range("string_view::substr"), basic_string_view())
: basic_string_view(data() + __pos, _VSTD::min(__n, size() - __pos));
}

View File

@ -20,7 +20,7 @@ inline bool capture_error_or_throw(std::error_code* user_ec,
*user_ec = my_ec;
return true;
}
__libcpp_throw(filesystem_error(msg, std::forward<Args>(args)..., my_ec));
__throw_filesystem_error(msg, std::forward<Args>(args)..., my_ec);
return false;
}
@ -33,7 +33,7 @@ inline bool set_or_throw(std::error_code& my_ec,
*user_ec = my_ec;
return true;
}
__libcpp_throw(filesystem_error(msg, std::forward<Args>(args)..., my_ec));
__throw_filesystem_error(msg, std::forward<Args>(args)..., my_ec);
return false;
}

View File

@ -51,7 +51,7 @@ void set_or_throw(std::error_code const& m_ec, std::error_code* ec,
} else {
string msg_s("std::experimental::filesystem::");
msg_s += msg;
__libcpp_throw(filesystem_error(msg_s, p, p2, m_ec));
__throw_filesystem_error(msg_s, p, p2, m_ec);
}
}