[libcxx] r279763 - 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.

Marshall Clow via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 25 10:47:10 PDT 2016


Author: marshall
Date: Thu Aug 25 12:47:09 2016
New Revision: 279763

URL: http://llvm.org/viewvc/llvm-project?rev=279763&view=rev
Log:
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.

Modified:
    libcxx/trunk/include/any
    libcxx/trunk/include/exception
    libcxx/trunk/include/experimental/filesystem
    libcxx/trunk/include/experimental/memory_resource
    libcxx/trunk/include/experimental/string_view
    libcxx/trunk/include/memory
    libcxx/trunk/include/string_view
    libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
    libcxx/trunk/src/experimental/filesystem/operations.cpp

Modified: libcxx/trunk/include/any
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/any?rev=279763&r1=279762&r2=279763&view=diff
==============================================================================
--- libcxx/trunk/include/any (original)
+++ libcxx/trunk/include/any Thu Aug 25 12:47:09 2016
@@ -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);
 }
 

Modified: libcxx/trunk/include/exception
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/exception?rev=279763&r1=279762&r2=279763&view=diff
==============================================================================
--- libcxx/trunk/include/exception (original)
+++ libcxx/trunk/include/exception Thu Aug 25 12:47:09 2016
@@ -255,19 +255,4 @@ rethrow_if_nested(const _Ep&, typename e
 
 }  // 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

Modified: libcxx/trunk/include/experimental/filesystem
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/filesystem?rev=279763&r1=279762&r2=279763&view=diff
==============================================================================
--- libcxx/trunk/include/experimental/filesystem (original)
+++ libcxx/trunk/include/experimental/filesystem Thu Aug 25 12:47:09 2016
@@ -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

Modified: libcxx/trunk/include/experimental/memory_resource
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/memory_resource?rev=279763&r1=279762&r2=279763&view=diff
==============================================================================
--- libcxx/trunk/include/experimental/memory_resource (original)
+++ libcxx/trunk/include/experimental/memory_resource Thu Aug 25 12:47:09 2016
@@ -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);

Modified: libcxx/trunk/include/experimental/string_view
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/string_view?rev=279763&r1=279762&r2=279763&view=diff
==============================================================================
--- libcxx/trunk/include/experimental/string_view (original)
+++ libcxx/trunk/include/experimental/string_view Thu Aug 25 12:47:09 2016
@@ -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;

Modified: libcxx/trunk/include/memory
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=279763&r1=279762&r2=279763&view=diff
==============================================================================
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Thu Aug 25 12:47:09 2016
@@ -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

Modified: libcxx/trunk/include/string_view
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string_view?rev=279763&r1=279762&r2=279763&view=diff
==============================================================================
--- libcxx/trunk/include/string_view (original)
+++ libcxx/trunk/include/string_view Thu Aug 25 12:47:09 2016
@@ -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));
 	}
 

Modified: libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp?rev=279763&r1=279762&r2=279763&view=diff
==============================================================================
--- libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/directory_iterator.cpp Thu Aug 25 12:47:09 2016
@@ -20,7 +20,7 @@ inline bool capture_error_or_throw(std::
         *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
         *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;
 }
 

Modified: libcxx/trunk/src/experimental/filesystem/operations.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/operations.cpp?rev=279763&r1=279762&r2=279763&view=diff
==============================================================================
--- libcxx/trunk/src/experimental/filesystem/operations.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/operations.cpp Thu Aug 25 12:47:09 2016
@@ -51,7 +51,7 @@ void set_or_throw(std::error_code const&
     } 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);
     }
 }
 




More information about the cfe-commits mailing list