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

Marshall Clow via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 25 08:09:02 PDT 2016


Author: marshall
Date: Thu Aug 25 10:09:01 2016
New Revision: 279744

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

Modified:
    libcxx/trunk/include/__functional_03
    libcxx/trunk/include/__locale
    libcxx/trunk/include/any
    libcxx/trunk/include/array
    libcxx/trunk/include/bitset
    libcxx/trunk/include/complex
    libcxx/trunk/include/deque
    libcxx/trunk/include/experimental/any
    libcxx/trunk/include/experimental/dynarray
    libcxx/trunk/include/experimental/optional
    libcxx/trunk/include/experimental/string_view
    libcxx/trunk/include/fstream
    libcxx/trunk/include/functional
    libcxx/trunk/include/future
    libcxx/trunk/include/locale
    libcxx/trunk/include/memory
    libcxx/trunk/include/new
    libcxx/trunk/include/regex
    libcxx/trunk/include/stdexcept
    libcxx/trunk/include/string
    libcxx/trunk/include/typeinfo
    libcxx/trunk/include/vector
    libcxx/trunk/src/debug.cpp
    libcxx/trunk/src/experimental/memory_resource.cpp
    libcxx/trunk/src/locale.cpp
    libcxx/trunk/src/new.cpp
    libcxx/trunk/src/string.cpp
    libcxx/trunk/src/system_error.cpp
    libcxx/trunk/src/thread.cpp
    libcxx/trunk/src/typeinfo.cpp

Modified: libcxx/trunk/include/__functional_03
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__functional_03?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/include/__functional_03 (original)
+++ libcxx/trunk/include/__functional_03 Thu Aug 25 10:09:01 2016
@@ -679,10 +679,8 @@ template<class _Rp>
 _Rp
 function<_Rp()>::operator()() const
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__f_ == 0)
-        throw bad_function_call();
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_bad_function_call();
     return (*__f_)();
 }
 
@@ -955,10 +953,8 @@ template<class _Rp, class _A0>
 _Rp
 function<_Rp(_A0)>::operator()(_A0 __a0) const
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__f_ == 0)
-        throw bad_function_call();
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_bad_function_call();
     return (*__f_)(__a0);
 }
 
@@ -1231,10 +1227,8 @@ template<class _Rp, class _A0, class _A1
 _Rp
 function<_Rp(_A0, _A1)>::operator()(_A0 __a0, _A1 __a1) const
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__f_ == 0)
-        throw bad_function_call();
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_bad_function_call();
     return (*__f_)(__a0, __a1);
 }
 
@@ -1507,10 +1501,8 @@ template<class _Rp, class _A0, class _A1
 _Rp
 function<_Rp(_A0, _A1, _A2)>::operator()(_A0 __a0, _A1 __a1, _A2 __a2) const
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__f_ == 0)
-        throw bad_function_call();
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_bad_function_call();
     return (*__f_)(__a0, __a1, __a2);
 }
 

Modified: libcxx/trunk/include/__locale
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__locale?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/include/__locale (original)
+++ libcxx/trunk/include/__locale Thu Aug 25 10:09:01 2016
@@ -165,10 +165,9 @@ template <class _Facet>
 locale
 locale::combine(const locale& __other) const
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (!_VSTD::has_facet<_Facet>(__other))
-        throw runtime_error("locale::combine: locale missing facet");
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_runtime_error("locale::combine: locale missing facet");
+
     return locale(*this, &const_cast<_Facet&>(_VSTD::use_facet<_Facet>(__other)));
 }
 
@@ -1184,8 +1183,6 @@ _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_T
 _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>)
 _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>)
 
-_LIBCPP_FUNC_VIS void __throw_runtime_error(const char*);
-
 template <size_t _Np>
 struct __narrow_to_utf8
 {

Modified: libcxx/trunk/include/any
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/any?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/include/any (original)
+++ libcxx/trunk/include/any Thu Aug 25 10:09:01 2016
@@ -85,7 +85,6 @@ namespace std {
 #include <typeinfo>
 #include <type_traits>
 #include <cstdlib>
-#include <cassert>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header

Modified: libcxx/trunk/include/array
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/array?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/include/array (original)
+++ libcxx/trunk/include/array Thu Aug 25 10:09:01 2016
@@ -108,9 +108,6 @@ template <size_t I, class T, size_t N> c
 #include <iterator>
 #include <algorithm>
 #include <stdexcept>
-#if defined(_LIBCPP_NO_EXCEPTIONS)
-    #include <cassert>
-#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -209,11 +206,8 @@ typename array<_Tp, _Size>::reference
 array<_Tp, _Size>::at(size_type __n)
 {
     if (__n >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-        throw out_of_range("array::at");
-#else
-        assert(!"array::at out_of_range");
-#endif
+        __throw_out_of_range("array::at");
+
     return __elems_[__n];
 }
 
@@ -223,11 +217,7 @@ typename array<_Tp, _Size>::const_refere
 array<_Tp, _Size>::at(size_type __n) const
 {
     if (__n >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-        throw out_of_range("array::at");
-#else
-        assert(!"array::at out_of_range");
-#endif
+        __throw_out_of_range("array::at");
     return __elems_[__n];
 }
 

Modified: libcxx/trunk/include/bitset
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/bitset?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/include/bitset (original)
+++ libcxx/trunk/include/bitset Thu Aug 25 10:09:01 2016
@@ -125,9 +125,6 @@ template <size_t N> struct hash<std::bit
 #include <stdexcept>
 #include <iosfwd>
 #include <__functional_base>
-#if defined(_LIBCPP_NO_EXCEPTIONS)
-    #include <cassert>
-#endif
 
 #include <__undef_min_max>
 
@@ -326,11 +323,8 @@ __bitset<_N_words, _Size>::to_ulong(fals
     const_iterator __e = __make_iter(_Size);
     const_iterator __i = _VSTD::find(__make_iter(sizeof(unsigned long) * CHAR_BIT), __e, true);
     if (__i != __e)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-        throw overflow_error("bitset to_ulong overflow error");
-#else
-        assert(!"bitset to_ulong overflow error");
-#endif
+        __throw_overflow_error("bitset to_ulong overflow error");
+
     return __first_[0];
 }
 
@@ -349,11 +343,8 @@ __bitset<_N_words, _Size>::to_ullong(fal
     const_iterator __e = __make_iter(_Size);
     const_iterator __i = _VSTD::find(__make_iter(sizeof(unsigned long long) * CHAR_BIT), __e, true);
     if (__i != __e)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-        throw overflow_error("bitset to_ullong overflow error");
-#else
-        assert(!"bitset to_ullong overflow error");
-#endif
+        __throw_overflow_error("bitset to_ullong overflow error");
+
     return to_ullong(true_type());
 }
 
@@ -763,11 +754,8 @@ bitset<_Size>::bitset(const _CharT* __st
     size_t __rlen = _VSTD::min(__n, char_traits<_CharT>::length(__str));
     for (size_t __i = 0; __i < __rlen; ++__i)
         if (__str[__i] != __zero && __str[__i] != __one)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-            throw invalid_argument("bitset string ctor has invalid argument");
-#else
-            assert(!"bitset string ctor has invalid argument");
-#endif
+            __throw_invalid_argument("bitset string ctor has invalid argument");
+
     size_t _Mp = _VSTD::min(__rlen, _Size);
     size_t __i = 0;
     for (; __i < _Mp; ++__i)
@@ -789,19 +777,13 @@ bitset<_Size>::bitset(const basic_string
        _CharT __zero, _CharT __one)
 {
     if (__pos > __str.size())
-#ifndef _LIBCPP_NO_EXCEPTIONS
-        throw out_of_range("bitset string pos out of range");
-#else
-        assert(!"bitset string pos out of range");
-#endif
+        __throw_out_of_range("bitset string pos out of range");
+
     size_t __rlen = _VSTD::min(__n, __str.size() - __pos);
     for (size_t __i = __pos; __i < __pos + __rlen; ++__i)
         if (!_Traits::eq(__str[__i], __zero) && !_Traits::eq(__str[__i], __one))
-#ifndef _LIBCPP_NO_EXCEPTIONS
-            throw invalid_argument("bitset string ctor has invalid argument");
-#else
-            assert(!"bitset string ctor has invalid argument");
-#endif
+            __throw_invalid_argument("bitset string ctor has invalid argument");
+
     size_t _Mp = _VSTD::min(__rlen, _Size);
     size_t __i = 0;
     for (; __i < _Mp; ++__i)
@@ -876,11 +858,8 @@ bitset<_Size>&
 bitset<_Size>::set(size_t __pos, bool __val)
 {
     if (__pos >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-        throw out_of_range("bitset set argument out of range");
-#else
-        assert(!"bitset set argument out of range");
-#endif
+        __throw_out_of_range("bitset set argument out of range");
+
     (*this)[__pos] = __val;
     return *this;
 }
@@ -899,11 +878,8 @@ bitset<_Size>&
 bitset<_Size>::reset(size_t __pos)
 {
     if (__pos >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-        throw out_of_range("bitset reset argument out of range");
-#else
-        assert(!"bitset reset argument out of range");
-#endif
+        __throw_out_of_range("bitset reset argument out of range");
+
     (*this)[__pos] = false;
     return *this;
 }
@@ -932,11 +908,8 @@ bitset<_Size>&
 bitset<_Size>::flip(size_t __pos)
 {
     if (__pos >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-        throw out_of_range("bitset flip argument out of range");
-#else
-        assert(!"bitset flip argument out of range");
-#endif
+        __throw_out_of_range("bitset flip argument out of range");
+
     reference r = base::__make_ref(__pos);
     r = ~r;
     return *this;
@@ -1027,11 +1000,8 @@ bool
 bitset<_Size>::test(size_t __pos) const
 {
     if (__pos >= _Size)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-        throw out_of_range("bitset test argument out of range");
-#else
-        assert(!"bitset test argument out of range");
-#endif
+        __throw_out_of_range("bitset test argument out of range");
+
     return (*this)[__pos];
 }
 

Modified: libcxx/trunk/include/complex
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/complex?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/include/complex (original)
+++ libcxx/trunk/include/complex Thu Aug 25 10:09:01 2016
@@ -245,9 +245,6 @@ template<class T, class charT, class tra
 #include <stdexcept>
 #include <cmath>
 #include <sstream>
-#if defined(_LIBCPP_NO_EXCEPTIONS)
-    #include <cassert>
-#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header

Modified: libcxx/trunk/include/deque
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/deque?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/include/deque (original)
+++ libcxx/trunk/include/deque Thu Aug 25 10:09:01 2016
@@ -895,26 +895,22 @@ template <bool>
 class __deque_base_common
 {
 protected:
-    void __throw_length_error() const;
-    void __throw_out_of_range() const;
+    _LIBCPP_NORETURN void __throw_length_error() const;
+    _LIBCPP_NORETURN void __throw_out_of_range() const;
 };
 
 template <bool __b>
 void
 __deque_base_common<__b>::__throw_length_error() const
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
-    throw length_error("deque");
-#endif
+    _VSTD::__throw_length_error("deque");
 }
 
 template <bool __b>
 void
 __deque_base_common<__b>::__throw_out_of_range() const
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
-    throw out_of_range("deque");
-#endif
+    _VSTD::__throw_out_of_range("deque");
 }
 
 template <class _Tp, class _Allocator>

Modified: libcxx/trunk/include/experimental/any
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/any?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/include/experimental/any (original)
+++ libcxx/trunk/include/experimental/any Thu Aug 25 10:09:01 2016
@@ -82,7 +82,6 @@ inline namespace fundamentals_v1 {
 #include <typeinfo>
 #include <type_traits>
 #include <cstdlib>
-#include <cassert>
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
@@ -98,13 +97,13 @@ public:
 
 #if _LIBCPP_STD_VER > 11                                            // C++ > 11
 
-_LIBCPP_NORETURN _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
 inline void __throw_bad_any_cast()
 {
 #ifndef _LIBCPP_NO_EXCEPTIONS
     throw bad_any_cast();
 #else
-    assert(!"bad_any_cast");
+    _VSTD::abort();
 #endif
 }
 

Modified: libcxx/trunk/include/experimental/dynarray
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/dynarray?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/include/experimental/dynarray (original)
+++ libcxx/trunk/include/experimental/dynarray Thu Aug 25 10:09:01 2016
@@ -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];
 }
 

Modified: libcxx/trunk/include/experimental/optional
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/optional?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/include/experimental/optional (original)
+++ libcxx/trunk/include/experimental/optional Thu Aug 25 10:09:01 2016
@@ -513,15 +513,21 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     constexpr explicit operator bool() const noexcept {return this->__engaged_;}
 
+	_LIBCPP_NORETURN _LIBCPP_INLINE_VISIBILITY 
+	constexpr void __throw_bad_optional_access() const
+	{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+        throw bad_optional_access();
+#else
+        _VSTD::abort();
+#endif
+	}
+	
     _LIBCPP_INLINE_VISIBILITY
     constexpr value_type const& value() const
     {
         if (!this->__engaged_)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-            throw bad_optional_access();
-#else
-            assert(!"bad optional access");
-#endif
+            __throw_bad_optional_access();
         return this->__val_;
     }
 
@@ -529,11 +535,7 @@ public:
     value_type& value()
     {
         if (!this->__engaged_)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-            throw bad_optional_access();
-#else
-            assert(!"bad optional access");
-#endif
+            __throw_bad_optional_access();
         return this->__val_;
     }
 

Modified: libcxx/trunk/include/experimental/string_view
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/string_view?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/include/experimental/string_view (original)
+++ libcxx/trunk/include/experimental/string_view Thu Aug 25 10:09:01 2016
@@ -362,11 +362,11 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
         basic_string_view substr(size_type __pos = 0, size_type __n = npos) const
         {
 //             if (__pos > size())
-//                 throw out_of_range("string_view::substr");
+//                 __throw_out_of_range("string_view::substr");
 //             size_type __rlen = _VSTD::min( __n, size() - __pos );
 //             return basic_string_view(data() + __pos, __rlen);
             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/include/fstream
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/fstream?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/include/fstream (original)
+++ libcxx/trunk/include/fstream Thu Aug 25 10:09:01 2016
@@ -618,10 +618,9 @@ basic_filebuf<_CharT, _Traits>::underflo
             size_t __nr = fread((void*)__extbufnext_, 1, __nmemb, __file_);
             if (__nr != 0)
             {
-#ifndef _LIBCPP_NO_EXCEPTIONS
                 if (!__cv_)
-                    throw bad_cast();
-#endif
+                    __throw_bad_cast();
+
                 __extbufend_ = __extbufnext_ + __nr;
                 char_type*  __inext;
                 __r = __cv_->in(__st_, __extbuf_, __extbufend_, __extbufnext_,
@@ -700,10 +699,9 @@ basic_filebuf<_CharT, _Traits>::overflow
             codecvt_base::result __r;
             do
             {
-#ifndef _LIBCPP_NO_EXCEPTIONS
                 if (!__cv_)
-                    throw bad_cast();
-#endif
+                    __throw_bad_cast();
+
                 const char_type* __e;
                 __r = __cv_->out(__st_, this->pbase(), this->pptr(), __e,
                                         __extbuf_, __extbuf_ + __ebs_, __extbe);
@@ -793,10 +791,9 @@ typename basic_filebuf<_CharT, _Traits>:
 basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way,
                                         ios_base::openmode)
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (!__cv_)
-        throw bad_cast();
-#endif
+        __throw_bad_cast();
+
     int __width = __cv_->encoding();
     if (__file_ == 0 || (__width <= 0 && __off != 0) || sync())
         return pos_type(off_type(-1));
@@ -852,10 +849,9 @@ basic_filebuf<_CharT, _Traits>::sync()
 {
     if (__file_ == 0)
         return 0;
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (!__cv_)
-        throw bad_cast();
-#endif
+        __throw_bad_cast();
+
     if (__cm_ & ios_base::out)
     {
         if (this->pptr() != this->pbase())

Modified: libcxx/trunk/include/functional
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/functional?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/include/functional (original)
+++ libcxx/trunk/include/functional Thu Aug 25 10:09:01 2016
@@ -1382,6 +1382,16 @@ class _LIBCPP_EXCEPTION_ABI bad_function
 {
 };
 
+_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
+void __throw_bad_function_call()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw bad_function_call();
+#else
+	_VSTD::abort();
+#endif
+}
+
 template<class _Fp> class _LIBCPP_TYPE_VIS_ONLY function; // undefined
 
 namespace __function
@@ -1882,10 +1892,8 @@ template<class _Rp, class ..._ArgTypes>
 _Rp
 function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__f_ == 0)
-        throw bad_function_call();
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_bad_function_call();
     return (*__f_)(_VSTD::forward<_ArgTypes>(__arg)...);
 }
 

Modified: libcxx/trunk/include/future
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/future?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/include/future (original)
+++ libcxx/trunk/include/future Thu Aug 25 10:09:01 2016
@@ -512,13 +512,13 @@ public:
     virtual ~future_error() _NOEXCEPT;
 };
 
-inline _LIBCPP_ALWAYS_INLINE
+_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
 void __throw_future_error(future_errc _Ev)
 {
 #ifndef _LIBCPP_NO_EXCEPTIONS
     throw future_error(make_error_code(_Ev));
 #else
-    assert(!"future_error");
+    _VSTD::abort();
 #endif
 }
 

Modified: libcxx/trunk/include/locale
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/locale?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/include/locale (original)
+++ libcxx/trunk/include/locale Thu Aug 25 10:09:01 2016
@@ -3701,10 +3701,10 @@ wstring_convert<_Codecvt, _Elem, _Wide_a
         if (__r == codecvt_base::ok)
             return __ws;
     }
-#ifndef _LIBCPP_NO_EXCEPTIONS
+
     if (__wide_err_string_.empty())
-        throw range_error("wstring_convert: from_bytes error");
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_range_error("wstring_convert: from_bytes error");
+
     return __wide_err_string_;
 }
 
@@ -3790,10 +3790,10 @@ wstring_convert<_Codecvt, _Elem, _Wide_a
                 return __bs;
         }
     }
-#ifndef _LIBCPP_NO_EXCEPTIONS
+
     if (__byte_err_string_.empty())
-        throw range_error("wstring_convert: to_bytes error");
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_range_error("wstring_convert: to_bytes error");
+
     return __byte_err_string_;
 }
 

Modified: libcxx/trunk/include/memory
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Thu Aug 25 10:09:01 2016
@@ -637,9 +637,6 @@ void* align(size_t alignment, size_t siz
 #include <tuple>
 #include <stdexcept>
 #include <cstring>
-#if defined(_LIBCPP_NO_EXCEPTIONS)
-    #include <cassert>
-#endif
 
 #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
 #  include <atomic>
@@ -3787,6 +3784,16 @@ public:
     virtual const char* what() const  _NOEXCEPT;
 };
 
+_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
+void __throw_bad_weak_ptr()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw bad_weak_ptr();
+#else
+    _VSTD::abort();
+#endif
+}
+
 template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY weak_ptr;
 
 class _LIBCPP_TYPE_VIS __shared_count
@@ -5443,11 +5450,7 @@ shared_ptr<_Tp>::shared_ptr(const weak_p
       __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_)
 {
     if (__cntrl_ == 0)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-        throw bad_weak_ptr();
-#else
-        assert(!"bad_weak_ptr");
-#endif
+        __throw_bad_weak_ptr();
 }
 
 template<class _Tp>

Modified: libcxx/trunk/include/new
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/new?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/include/new (original)
+++ libcxx/trunk/include/new Thu Aug 25 10:09:01 2016
@@ -97,6 +97,8 @@ public:
     virtual const char* what() const _NOEXCEPT;
 };
 
+_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_bad_alloc();  // not in C++ spec
+
 #if defined(_LIBCPP_BUILDING_NEW) || (_LIBCPP_STD_VER > 11)
 
 class _LIBCPP_EXCEPTION_ABI bad_array_length
@@ -112,8 +114,6 @@ public:
 
 #endif  // defined(_LIBCPP_BUILDING_NEW) || (_LIBCPP_STD_VER > 11)
 
-_LIBCPP_FUNC_VIS void __throw_bad_alloc();  // not in C++ spec
-
 struct _LIBCPP_TYPE_VIS nothrow_t {};
 extern _LIBCPP_FUNC_VIS const nothrow_t nothrow;
 typedef void (*new_handler)();
@@ -177,6 +177,18 @@ inline _LIBCPP_INLINE_VISIBILITY void __
 #endif
 }
 
+#ifdef _LIBCPP_BAD_ARRAY_LENGTH_DEFINED
+_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
+void __throw_bad_array_length()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw bad_array_length();
+#else
+	_VSTD::abort();
+#endif
+}
+#endif
+
 _LIBCPP_END_NAMESPACE_STD
 
 #endif  // _LIBCPP_NEW

Modified: libcxx/trunk/include/regex
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/regex?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/include/regex (original)
+++ libcxx/trunk/include/regex Thu Aug 25 10:09:01 2016
@@ -764,7 +764,6 @@ typedef regex_token_iterator<wstring::co
 #include <memory>
 #include <vector>
 #include <deque>
-#include <cassert>
 
 #include <__undef_min_max>
 
@@ -959,13 +958,13 @@ public:
 };
 
 template <regex_constants::error_type _Ev>
-_LIBCPP_ALWAYS_INLINE
+_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
 void __throw_regex_error()
 {
 #ifndef _LIBCPP_NO_EXCEPTIONS
     throw regex_error(_Ev);
 #else
-    assert(!"regex_error");
+    _VSTD::abort();
 #endif
 }
 

Modified: libcxx/trunk/include/stdexcept
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/stdexcept?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/include/stdexcept (original)
+++ libcxx/trunk/include/stdexcept Thu Aug 25 10:09:01 2016
@@ -171,4 +171,91 @@ public:
 
 }  // std
 
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// in the dylib
+_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_runtime_error(const char*);
+
+_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
+void __throw_logic_error(const char*__msg)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw logic_error(__msg);
+#else
+	_VSTD::abort();
+#endif
+}
+
+_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
+void __throw_domain_error(const char*__msg)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw domain_error(__msg);
+#else
+	_VSTD::abort();
+#endif
+}
+
+_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
+void __throw_invalid_argument(const char*__msg)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw invalid_argument(__msg);
+#else
+	_VSTD::abort();
+#endif
+}
+
+_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
+void __throw_length_error(const char*__msg)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw length_error(__msg);
+#else
+	_VSTD::abort();
+#endif
+}
+
+_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
+void __throw_out_of_range(const char*__msg)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw out_of_range(__msg);
+#else
+	_VSTD::abort();
+#endif
+}
+
+_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
+void __throw_range_error(const char*__msg)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw range_error(__msg);
+#else
+	_VSTD::abort();
+#endif
+}
+
+_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
+void __throw_overflow_error(const char*__msg)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw overflow_error(__msg);
+#else
+	_VSTD::abort();
+#endif
+}
+
+_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
+void __throw_underflow_error(const char*__msg)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw underflow_error(__msg);
+#else
+	_VSTD::abort();
+#endif
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
 #endif  // _LIBCPP_STDEXCEPT

Modified: libcxx/trunk/include/string
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Thu Aug 25 10:09:01 2016
@@ -477,10 +477,6 @@ basic_string<char32_t> operator "" s( co
 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
 #include <cstdint>
 #endif
-#if defined(_LIBCPP_NO_EXCEPTIONS)
-#include <cassert>
-#endif
-
 
 #include <__undef_min_max>
 
@@ -556,30 +552,22 @@ template <bool>
 class _LIBCPP_TYPE_VIS_ONLY __basic_string_common
 {
 protected:
-    void __throw_length_error() const;
-    void __throw_out_of_range() const;
+    _LIBCPP_NORETURN void __throw_length_error() const;
+    _LIBCPP_NORETURN void __throw_out_of_range() const;
 };
 
 template <bool __b>
 void
 __basic_string_common<__b>::__throw_length_error() const
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
-    throw length_error("basic_string");
-#else
-    assert(!"basic_string length_error");
-#endif
+    _VSTD::__throw_length_error("basic_string");
 }
 
 template <bool __b>
 void
 __basic_string_common<__b>::__throw_out_of_range() const
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
-    throw out_of_range("basic_string");
-#else
-    assert(!"basic_string out_of_range");
-#endif
+    _VSTD::__throw_out_of_range("basic_string");
 }
 
 #ifdef _LIBCPP_MSVC

Modified: libcxx/trunk/include/typeinfo
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/typeinfo?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/include/typeinfo (original)
+++ libcxx/trunk/include/typeinfo Thu Aug 25 10:09:01 2016
@@ -165,4 +165,16 @@ public:
 
 }  // std
 
+_LIBCPP_BEGIN_NAMESPACE_STD
+_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
+void __throw_bad_cast()
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw bad_cast();
+#else
+	_VSTD::abort();
+#endif
+}
+_LIBCPP_END_NAMESPACE_STD
+
 #endif  // __LIBCPP_TYPEINFO

Modified: libcxx/trunk/include/vector
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/vector?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/include/vector (original)
+++ libcxx/trunk/include/vector Thu Aug 25 10:09:01 2016
@@ -290,30 +290,22 @@ class __vector_base_common
 {
 protected:
     _LIBCPP_ALWAYS_INLINE __vector_base_common() {}
-    void __throw_length_error() const;
-    void __throw_out_of_range() const;
+    _LIBCPP_NORETURN void __throw_length_error() const;
+    _LIBCPP_NORETURN void __throw_out_of_range() const;
 };
 
 template <bool __b>
 void
 __vector_base_common<__b>::__throw_length_error() const
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
-    throw length_error("vector");
-#else
-    assert(!"vector length_error");
-#endif
+    _VSTD::__throw_length_error("vector");
 }
 
 template <bool __b>
 void
 __vector_base_common<__b>::__throw_out_of_range() const
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
-    throw out_of_range("vector");
-#else
-    assert(!"vector out_of_range");
-#endif
+    _VSTD::__throw_out_of_range("vector");
 }
 
 #ifdef _LIBCPP_MSVC

Modified: libcxx/trunk/src/debug.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/debug.cpp?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/src/debug.cpp (original)
+++ libcxx/trunk/src/debug.cpp Thu Aug 25 10:09:01 2016
@@ -152,11 +152,8 @@ __libcpp_db::__insert_c(void* __c)
         size_t nc = __next_prime(2*static_cast<size_t>(__cend_ - __cbeg_) + 1);
         __c_node** cbeg = static_cast<__c_node**>(calloc(nc, sizeof(void*)));
         if (cbeg == nullptr)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-            throw bad_alloc();
-#else
-            abort();
-#endif
+            __throw_bad_alloc();
+
         for (__c_node** p = __cbeg_; p != __cend_; ++p)
         {
             __c_node* q = *p;
@@ -178,11 +175,8 @@ __libcpp_db::__insert_c(void* __c)
     __c_node* r = __cbeg_[hc] =
       static_cast<__c_node*>(malloc(sizeof(__c_node)));
     if (__cbeg_[hc] == nullptr)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-        throw bad_alloc();
-#else
-        abort();
-#endif
+        __throw_bad_alloc();
+
     r->__c_ = __c;
     r->__next_ = p;
     ++__csz_;
@@ -475,11 +469,8 @@ __c_node::__add(__i_node* i)
         __i_node** beg =
            static_cast<__i_node**>(malloc(nc * sizeof(__i_node*)));
         if (beg == nullptr)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-            throw bad_alloc();
-#else
-            abort();
-#endif
+            __throw_bad_alloc();
+
         if (nc > 1)
             memcpy(beg, beg_, nc/2*sizeof(__i_node*));
         free(beg_);
@@ -501,11 +492,8 @@ __libcpp_db::__insert_iterator(void* __i
         size_t nc = __next_prime(2*static_cast<size_t>(__iend_ - __ibeg_) + 1);
         __i_node** ibeg = static_cast<__i_node**>(calloc(nc, sizeof(void*)));
         if (ibeg == nullptr)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-            throw bad_alloc();
-#else
-            abort();
-#endif
+            __throw_bad_alloc();
+
         for (__i_node** p = __ibeg_; p != __iend_; ++p)
         {
             __i_node* q = *p;
@@ -527,11 +515,8 @@ __libcpp_db::__insert_iterator(void* __i
     __i_node* r = __ibeg_[hi] =
       static_cast<__i_node*>(malloc(sizeof(__i_node)));
     if (r == nullptr)
-#ifndef _LIBCPP_NO_EXCEPTIONS
-        throw bad_alloc();
-#else
-        abort();
-#endif
+        __throw_bad_alloc();
+
     ::new(r) __i_node(__i, p, nullptr);
     ++__isz_;
     return r;

Modified: libcxx/trunk/src/experimental/memory_resource.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/memory_resource.cpp?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/src/experimental/memory_resource.cpp (original)
+++ libcxx/trunk/src/experimental/memory_resource.cpp Thu Aug 25 10:09:01 2016
@@ -50,11 +50,7 @@ public:
 
 protected:
     virtual void* do_allocate(size_t, size_t) {
-#ifndef _LIBCPP_NO_EXCEPTIONS
-        throw std::bad_alloc();
-#else
-        abort();
-#endif
+        __throw_bad_alloc();
     }
     virtual void do_deallocate(void *, size_t, size_t) {}
     virtual bool do_is_equal(memory_resource const & __other) const _NOEXCEPT

Modified: libcxx/trunk/src/locale.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/locale.cpp?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/src/locale.cpp (original)
+++ libcxx/trunk/src/locale.cpp Thu Aug 25 10:09:01 2016
@@ -107,6 +107,16 @@ countof(const T * const begin, const T *
     return static_cast<size_t>(end - begin);
 }
 
+_LIBCPP_NORETURN static void __throw_runtime_error(const string &msg)
+{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+    throw runtime_error(msg);
+#else
+    (void)msg;
+    _VSTD::abort();
+#endif
+}
+
 }
 
 #if defined(_AIX)
@@ -646,22 +656,18 @@ collate_byname<char>::collate_byname(con
     : collate<char>(refs),
       __l(newlocale(LC_ALL_MASK, n, 0))
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__l == 0)
-        throw runtime_error("collate_byname<char>::collate_byname"
+        __throw_runtime_error("collate_byname<char>::collate_byname"
                             " failed to construct for " + string(n));
-#endif  // _LIBCPP_NO_EXCEPTIONS
 }
 
 collate_byname<char>::collate_byname(const string& name, size_t refs)
     : collate<char>(refs),
       __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__l == 0)
-        throw runtime_error("collate_byname<char>::collate_byname"
+        __throw_runtime_error("collate_byname<char>::collate_byname"
                             " failed to construct for " + name);
-#endif  // _LIBCPP_NO_EXCEPTIONS
 }
 
 collate_byname<char>::~collate_byname()
@@ -698,22 +704,18 @@ collate_byname<wchar_t>::collate_byname(
     : collate<wchar_t>(refs),
       __l(newlocale(LC_ALL_MASK, n, 0))
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__l == 0)
-        throw runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)"
+        __throw_runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)"
                             " failed to construct for " + string(n));
-#endif  // _LIBCPP_NO_EXCEPTIONS
 }
 
 collate_byname<wchar_t>::collate_byname(const string& name, size_t refs)
     : collate<wchar_t>(refs),
       __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__l == 0)
-        throw runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)"
+        __throw_runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)"
                             " failed to construct for " + name);
-#endif  // _LIBCPP_NO_EXCEPTIONS
 }
 
 collate_byname<wchar_t>::~collate_byname()
@@ -1172,22 +1174,18 @@ ctype_byname<char>::ctype_byname(const c
     : ctype<char>(0, false, refs),
       __l(newlocale(LC_ALL_MASK, name, 0))
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__l == 0)
-        throw runtime_error("ctype_byname<char>::ctype_byname"
+        __throw_runtime_error("ctype_byname<char>::ctype_byname"
                             " failed to construct for " + string(name));
-#endif  // _LIBCPP_NO_EXCEPTIONS
 }
 
 ctype_byname<char>::ctype_byname(const string& name, size_t refs)
     : ctype<char>(0, false, refs),
       __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__l == 0)
-        throw runtime_error("ctype_byname<char>::ctype_byname"
+        __throw_runtime_error("ctype_byname<char>::ctype_byname"
                             " failed to construct for " + name);
-#endif  // _LIBCPP_NO_EXCEPTIONS
 }
 
 ctype_byname<char>::~ctype_byname()
@@ -1229,22 +1227,18 @@ ctype_byname<wchar_t>::ctype_byname(cons
     : ctype<wchar_t>(refs),
       __l(newlocale(LC_ALL_MASK, name, 0))
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__l == 0)
-        throw runtime_error("ctype_byname<wchar_t>::ctype_byname"
+        __throw_runtime_error("ctype_byname<wchar_t>::ctype_byname"
                             " failed to construct for " + string(name));
-#endif  // _LIBCPP_NO_EXCEPTIONS
 }
 
 ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs)
     : ctype<wchar_t>(refs),
       __l(newlocale(LC_ALL_MASK, name.c_str(), 0))
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__l == 0)
-        throw runtime_error("ctype_byname<wchar_t>::ctype_byname"
+        __throw_runtime_error("ctype_byname<wchar_t>::ctype_byname"
                             " failed to construct for " + name);
-#endif  // _LIBCPP_NO_EXCEPTIONS
 }
 
 ctype_byname<wchar_t>::~ctype_byname()
@@ -1504,11 +1498,9 @@ codecvt<wchar_t, char, mbstate_t>::codec
     : locale::facet(refs),
       __l(newlocale(LC_ALL_MASK, nm, 0))
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__l == 0)
-        throw runtime_error("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname"
+        __throw_runtime_error("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname"
                             " failed to construct for " + string(nm));
-#endif  // _LIBCPP_NO_EXCEPTIONS
 }
 
 codecvt<wchar_t, char, mbstate_t>::~codecvt()
@@ -4257,11 +4249,10 @@ numpunct_byname<char>::__init(const char
     if (strcmp(nm, "C") != 0)
     {
         __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
-#ifndef _LIBCPP_NO_EXCEPTIONS
         if (loc == nullptr)
-            throw runtime_error("numpunct_byname<char>::numpunct_byname"
+            __throw_runtime_error("numpunct_byname<char>::numpunct_byname"
                                 " failed to construct for " + string(nm));
-#endif  // _LIBCPP_NO_EXCEPTIONS
+
         lconv* lc = __libcpp_localeconv_l(loc.get());
         if (*lc->decimal_point)
             __decimal_point_ = *lc->decimal_point;
@@ -4296,11 +4287,10 @@ numpunct_byname<wchar_t>::__init(const c
     if (strcmp(nm, "C") != 0)
     {
         __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
-#ifndef _LIBCPP_NO_EXCEPTIONS
         if (loc == nullptr)
-            throw runtime_error("numpunct_byname<char>::numpunct_byname"
+            __throw_runtime_error("numpunct_byname<char>::numpunct_byname"
                                 " failed to construct for " + string(nm));
-#endif  // _LIBCPP_NO_EXCEPTIONS
+
         lconv* lc = __libcpp_localeconv_l(loc.get());
         if (*lc->decimal_point)
             __decimal_point_ = *lc->decimal_point;
@@ -4703,21 +4693,17 @@ __time_get_c_storage<wchar_t>::__r() con
 __time_get::__time_get(const char* nm)
     : __loc_(newlocale(LC_ALL_MASK, nm, 0))
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__loc_ == 0)
-        throw runtime_error("time_get_byname"
+        __throw_runtime_error("time_get_byname"
                             " failed to construct for " + string(nm));
-#endif  // _LIBCPP_NO_EXCEPTIONS
 }
 
 __time_get::__time_get(const string& nm)
     : __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0))
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__loc_ == 0)
-        throw runtime_error("time_get_byname"
+        __throw_runtime_error("time_get_byname"
                             " failed to construct for " + nm);
-#endif  // _LIBCPP_NO_EXCEPTIONS
 }
 
 __time_get::~__time_get()
@@ -5363,21 +5349,17 @@ __time_get_storage<wchar_t>::__do_date_o
 __time_put::__time_put(const char* nm)
     : __loc_(newlocale(LC_ALL_MASK, nm, 0))
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__loc_ == 0)
-        throw runtime_error("time_put_byname"
+        __throw_runtime_error("time_put_byname"
                             " failed to construct for " + string(nm));
-#endif  // _LIBCPP_NO_EXCEPTIONS
 }
 
 __time_put::__time_put(const string& nm)
     : __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0))
 {
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__loc_ == 0)
-        throw runtime_error("time_put_byname"
+        __throw_runtime_error("time_put_byname"
                             " failed to construct for " + nm);
-#endif  // _LIBCPP_NO_EXCEPTIONS
 }
 
 __time_put::~__time_put()
@@ -5792,11 +5774,10 @@ moneypunct_byname<char, false>::init(con
 {
     typedef moneypunct<char, false> base;
     __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (loc == nullptr)
-        throw runtime_error("moneypunct_byname"
+        __throw_runtime_error("moneypunct_byname"
                             " failed to construct for " + string(nm));
-#endif  // _LIBCPP_NO_EXCEPTIONS
+
     lconv* lc = __libcpp_localeconv_l(loc.get());
     if (*lc->mon_decimal_point)
         __decimal_point_ = *lc->mon_decimal_point;
@@ -5836,11 +5817,10 @@ moneypunct_byname<char, true>::init(cons
 {
     typedef moneypunct<char, true> base;
     __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (loc == nullptr)
-        throw runtime_error("moneypunct_byname"
+        __throw_runtime_error("moneypunct_byname"
                             " failed to construct for " + string(nm));
-#endif  // _LIBCPP_NO_EXCEPTIONS
+
     lconv* lc = __libcpp_localeconv_l(loc.get());
     if (*lc->mon_decimal_point)
         __decimal_point_ = *lc->mon_decimal_point;
@@ -5897,11 +5877,9 @@ moneypunct_byname<wchar_t, false>::init(
 {
     typedef moneypunct<wchar_t, false> base;
     __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (loc == nullptr)
-        throw runtime_error("moneypunct_byname"
+        __throw_runtime_error("moneypunct_byname"
                             " failed to construct for " + string(nm));
-#endif  // _LIBCPP_NO_EXCEPTIONS
     lconv* lc = __libcpp_localeconv_l(loc.get());
     if (*lc->mon_decimal_point)
         __decimal_point_ = static_cast<wchar_t>(*lc->mon_decimal_point);
@@ -5964,11 +5942,10 @@ moneypunct_byname<wchar_t, true>::init(c
 {
     typedef moneypunct<wchar_t, true> base;
     __locale_unique_ptr loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
-#ifndef _LIBCPP_NO_EXCEPTIONS
     if (loc == nullptr)
-        throw runtime_error("moneypunct_byname"
+        __throw_runtime_error("moneypunct_byname"
                             " failed to construct for " + string(nm));
-#endif  // _LIBCPP_NO_EXCEPTIONS
+
     lconv* lc = __libcpp_localeconv_l(loc.get());
     if (*lc->mon_decimal_point)
         __decimal_point_ = static_cast<wchar_t>(*lc->mon_decimal_point);
@@ -6050,6 +6027,7 @@ void __throw_runtime_error(const char* m
     throw runtime_error(msg);
 #else
     (void)msg;
+    _VSTD::abort();
 #endif
 }
 

Modified: libcxx/trunk/src/new.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/new.cpp?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/src/new.cpp (original)
+++ libcxx/trunk/src/new.cpp Thu Aug 25 10:09:01 2016
@@ -241,6 +241,8 @@ __throw_bad_alloc()
 {
 #ifndef _LIBCPP_NO_EXCEPTIONS
     throw bad_alloc();
+#else
+    _VSTD::abort();
 #endif
 }
 

Modified: libcxx/trunk/src/string.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/string.cpp?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/src/string.cpp (original)
+++ libcxx/trunk/src/string.cpp Thu Aug 25 10:09:01 2016
@@ -40,7 +40,7 @@ void throw_helper( const string& msg )
     throw T( msg );
 #else
     fprintf(stderr, "%s\n", msg.c_str());
-    abort();
+    _VSTD::abort();
 #endif
 }
 

Modified: libcxx/trunk/src/system_error.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/system_error.cpp?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/src/system_error.cpp (original)
+++ libcxx/trunk/src/system_error.cpp Thu Aug 25 10:09:01 2016
@@ -258,6 +258,7 @@ __throw_system_error(int ev, const char*
 #else
     (void)ev;
     (void)what_arg;
+    _VSTD::abort();
 #endif
 }
 

Modified: libcxx/trunk/src/thread.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/thread.cpp?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/src/thread.cpp (original)
+++ libcxx/trunk/src/thread.cpp Thu Aug 25 10:09:01 2016
@@ -53,10 +53,9 @@ thread::join()
         if (ec == 0)
             __t_ = 0;
     }
-#ifndef _LIBCPP_NO_EXCEPTIONS
+
     if (ec)
-        throw system_error(error_code(ec, system_category()), "thread::join failed");
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_system_error(ec, "thread::join failed");
 }
 
 void
@@ -69,10 +68,9 @@ thread::detach()
         if (ec == 0)
             __t_ = 0;
     }
-#ifndef _LIBCPP_NO_EXCEPTIONS
+
     if (ec)
-        throw system_error(error_code(ec, system_category()), "thread::detach failed");
-#endif  // _LIBCPP_NO_EXCEPTIONS
+        __throw_system_error(ec, "thread::detach failed");
 }
 
 unsigned

Modified: libcxx/trunk/src/typeinfo.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/typeinfo.cpp?rev=279744&r1=279743&r2=279744&view=diff
==============================================================================
--- libcxx/trunk/src/typeinfo.cpp (original)
+++ libcxx/trunk/src/typeinfo.cpp Thu Aug 25 10:09:01 2016
@@ -54,12 +54,16 @@ std::bad_typeid::what() const _NOEXCEPT
   {
 #ifndef _LIBCPP_NO_EXCEPTIONS
      throw std::bad_typeid();
+#else
+     _VSTD::abort();
 #endif
   }
   void __cxxabiv1::__cxa_bad_cast()
   {
 #ifndef _LIBCPP_NO_EXCEPTIONS
       throw std::bad_cast();
+#else
+      _VSTD::abort();
 #endif
   }
 #endif




More information about the cfe-commits mailing list