summaryrefslogtreecommitdiffstats
path: root/libcxx/src/debug.cpp
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2016-08-25 15:09:01 +0000
committerMarshall Clow <mclow.lists@gmail.com>2016-08-25 15:09:01 +0000
commitd437fa5c8c1185af695b87cdd5ea83aa4a6e7382 (patch)
tree2fc9b60f206ef14e242a52af06f8f95b95693962 /libcxx/src/debug.cpp
parentb41b990e05797d1d69ea735bb168893974757422 (diff)
downloadbcm5719-llvm-d437fa5c8c1185af695b87cdd5ea83aa4a6e7382.tar.gz
bcm5719-llvm-d437fa5c8c1185af695b87cdd5ea83aa4a6e7382.zip
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
Diffstat (limited to 'libcxx/src/debug.cpp')
-rw-r--r--libcxx/src/debug.cpp35
1 files changed, 10 insertions, 25 deletions
diff --git a/libcxx/src/debug.cpp b/libcxx/src/debug.cpp
index b1a16e6e72d..d46935cc9ed 100644
--- a/libcxx/src/debug.cpp
+++ b/libcxx/src/debug.cpp
@@ -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;
OpenPOWER on IntegriCloud