summaryrefslogtreecommitdiffstats
path: root/libcxx/include/new
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/include/new
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/include/new')
-rw-r--r--libcxx/include/new16
1 files changed, 14 insertions, 2 deletions
diff --git a/libcxx/include/new b/libcxx/include/new
index d2b2ae648b4..95208671270 100644
--- a/libcxx/include/new
+++ b/libcxx/include/new
@@ -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 __deallocate(void *__ptr) {
#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
OpenPOWER on IntegriCloud