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.

llvm-svn: 279744
diff --git a/libcxx/src/debug.cpp b/libcxx/src/debug.cpp
index b1a16e6..d46935c 100644
--- a/libcxx/src/debug.cpp
+++ b/libcxx/src/debug.cpp
@@ -152,11 +152,8 @@
         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 @@
     __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 @@
         __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 @@
         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 @@
     __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;