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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@279763 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/any b/include/any
index 03d694e..6f742cb 100644
--- a/include/any
+++ b/include/any
@@ -102,6 +102,16 @@
 
 #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 @@
     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 @@
     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 @@
     >;
     _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/include/exception b/include/exception
index 186d379..a130bca 100644
--- a/include/exception
+++ b/include/exception
@@ -255,19 +255,4 @@
 
 }  // 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/include/experimental/filesystem b/include/experimental/filesystem
index 0075ad2..7211c6b 100644
--- a/include/experimental/filesystem
+++ b/include/experimental/filesystem
@@ -1176,6 +1176,17 @@
     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/include/experimental/memory_resource b/include/experimental/memory_resource
index 9b34521..1a2cb10 100644
--- a/include/experimental/memory_resource
+++ b/include/experimental/memory_resource
@@ -182,9 +182,9 @@
     _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 @@
     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/include/experimental/string_view b/include/experimental/string_view
index f8b5128..a62fe6e 100644
--- a/include/experimental/string_view
+++ b/include/experimental/string_view
@@ -281,7 +281,7 @@
         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 @@
         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/include/memory b/include/memory
index 7047bc7..31f58b7 100644
--- a/include/memory
+++ b/include/memory
@@ -1754,8 +1754,8 @@
     _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 @@
     _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/include/string_view b/include/string_view
index 67fc606..47ea926 100644
--- a/include/string_view
+++ b/include/string_view
@@ -261,7 +261,7 @@
 	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 @@
 	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 @@
 	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/src/experimental/filesystem/directory_iterator.cpp b/src/experimental/filesystem/directory_iterator.cpp
index fa217ba..a888dcf 100644
--- a/src/experimental/filesystem/directory_iterator.cpp
+++ b/src/experimental/filesystem/directory_iterator.cpp
@@ -20,7 +20,7 @@
         *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 @@
         *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/src/experimental/filesystem/operations.cpp b/src/experimental/filesystem/operations.cpp
index 369996f..cff27a0 100644
--- a/src/experimental/filesystem/operations.cpp
+++ b/src/experimental/filesystem/operations.cpp
@@ -51,7 +51,7 @@
     } 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);
     }
 }