summaryrefslogtreecommitdiffstats
path: root/libcxx
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx')
-rw-r--r--libcxx/include/any16
-rw-r--r--libcxx/include/exception15
-rw-r--r--libcxx/include/experimental/filesystem11
-rw-r--r--libcxx/include/experimental/memory_resource8
-rw-r--r--libcxx/include/experimental/string_view4
-rw-r--r--libcxx/include/memory8
-rw-r--r--libcxx/include/string_view6
-rw-r--r--libcxx/src/experimental/filesystem/directory_iterator.cpp4
-rw-r--r--libcxx/src/experimental/filesystem/operations.cpp2
9 files changed, 40 insertions, 34 deletions
diff --git a/libcxx/include/any b/libcxx/include/any
index 03d694edf2c..6f742cbdf73 100644
--- a/libcxx/include/any
+++ b/libcxx/include/any
@@ -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);
}
diff --git a/libcxx/include/exception b/libcxx/include/exception
index 186d379f08f..a130bca4e67 100644
--- a/libcxx/include/exception
+++ b/libcxx/include/exception
@@ -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
diff --git a/libcxx/include/experimental/filesystem b/libcxx/include/experimental/filesystem
index 0075ad2b084..7211c6b1efc 100644
--- a/libcxx/include/experimental/filesystem
+++ b/libcxx/include/experimental/filesystem
@@ -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
diff --git a/libcxx/include/experimental/memory_resource b/libcxx/include/experimental/memory_resource
index 9b345210ee5..1a2cb10bbec 100644
--- a/libcxx/include/experimental/memory_resource
+++ b/libcxx/include/experimental/memory_resource
@@ -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);
diff --git a/libcxx/include/experimental/string_view b/libcxx/include/experimental/string_view
index f8b51286c67..a62fe6e95a1 100644
--- a/libcxx/include/experimental/string_view
+++ b/libcxx/include/experimental/string_view
@@ -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;
diff --git a/libcxx/include/memory b/libcxx/include/memory
index 7047bc71729..31f58b7c0a4 100644
--- a/libcxx/include/memory
+++ b/libcxx/include/memory
@@ -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
diff --git a/libcxx/include/string_view b/libcxx/include/string_view
index 67fc60656f6..47ea926f637 100644
--- a/libcxx/include/string_view
+++ b/libcxx/include/string_view
@@ -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));
}
diff --git a/libcxx/src/experimental/filesystem/directory_iterator.cpp b/libcxx/src/experimental/filesystem/directory_iterator.cpp
index fa217ba7a12..a888dcfa119 100644
--- a/libcxx/src/experimental/filesystem/directory_iterator.cpp
+++ b/libcxx/src/experimental/filesystem/directory_iterator.cpp
@@ -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;
}
diff --git a/libcxx/src/experimental/filesystem/operations.cpp b/libcxx/src/experimental/filesystem/operations.cpp
index 369996fcbe6..cff27a0e54b 100644
--- a/libcxx/src/experimental/filesystem/operations.cpp
+++ b/libcxx/src/experimental/filesystem/operations.cpp
@@ -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);
}
}
OpenPOWER on IntegriCloud