[libcxxabi] r217604 - Adding ABI support for __cxa_throw_bad_array_new_length.
Aaron Ballman
aaron at aaronballman.com
Thu Sep 11 10:26:43 PDT 2014
Author: aaronballman
Date: Thu Sep 11 12:26:43 2014
New Revision: 217604
URL: http://llvm.org/viewvc/llvm-project?rev=217604&view=rev
Log:
Adding ABI support for __cxa_throw_bad_array_new_length.
Added:
libcxxabi/trunk/test/test_aux_runtime_op_array_new.cpp
Modified:
libcxxabi/trunk/CREDITS.TXT
libcxxabi/trunk/include/cxxabi.h
libcxxabi/trunk/src/cxa_aux_runtime.cpp
Modified: libcxxabi/trunk/CREDITS.TXT
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CREDITS.TXT?rev=217604&r1=217603&r2=217604&view=diff
==============================================================================
--- libcxxabi/trunk/CREDITS.TXT (original)
+++ libcxxabi/trunk/CREDITS.TXT Thu Sep 11 12:26:43 2014
@@ -8,6 +8,10 @@ beautification by scripts. The fields a
(W), PGP key ID and fingerprint (P), description (D), and snail-mail address
(S).
+N: Aaron Ballman
+E: aaron at aaronballman.com
+D: Minor patches
+
N: Logan Chien
E: logan.chien at mediatek.com
D: ARM EHABI Unwind & Exception Handling
Modified: libcxxabi/trunk/include/cxxabi.h
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/include/cxxabi.h?rev=217604&r1=217603&r2=217604&view=diff
==============================================================================
--- libcxxabi/trunk/include/cxxabi.h (original)
+++ libcxxabi/trunk/include/cxxabi.h Thu Sep 11 12:26:43 2014
@@ -66,6 +66,7 @@ extern LIBCXXABI_NORETURN void __cxa_ret
// 2.6 Auxiliary Runtime APIs
extern LIBCXXABI_NORETURN void __cxa_bad_cast(void);
extern LIBCXXABI_NORETURN void __cxa_bad_typeid(void);
+extern LIBCXXABI_NORETURN void __cxa_throw_bad_array_new_length(void);
Modified: libcxxabi/trunk/src/cxa_aux_runtime.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_aux_runtime.cpp?rev=217604&r1=217603&r2=217604&view=diff
==============================================================================
--- libcxxabi/trunk/src/cxa_aux_runtime.cpp (original)
+++ libcxxabi/trunk/src/cxa_aux_runtime.cpp Thu Sep 11 12:26:43 2014
@@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//
#include "cxxabi.h"
+#include <new>
#include <typeinfo>
namespace __cxxabiv1
@@ -29,6 +30,10 @@ void __cxa_bad_typeid(void) {
throw std::bad_typeid();
}
+LIBCXXABI_NORETURN
+void __cxa_throw_bad_array_new_length(void) {
+ throw std::bad_array_new_length();
+}
} // extern "C"
} // abi
Added: libcxxabi/trunk/test/test_aux_runtime_op_array_new.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_aux_runtime_op_array_new.cpp?rev=217604&view=auto
==============================================================================
--- libcxxabi/trunk/test/test_aux_runtime_op_array_new.cpp (added)
+++ libcxxabi/trunk/test/test_aux_runtime_op_array_new.cpp Thu Sep 11 12:26:43 2014
@@ -0,0 +1,38 @@
+//===-------------------------- test_aux_runtime_op_array_new.cpp ---------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <iostream>
+#include <cxxabi.h>
+
+// If the expression passed to operator new[] would result in an overflow, the
+// allocation function is not called, and a std::bad_array_new_length exception
+// is thrown instead (5.3.4p7).
+bool bad_array_new_length_test() {
+ try {
+ // We test this directly because Clang does not currently codegen the
+ // correct call to __cxa_bad_array_new_length, so this test would result
+ // in passing -1 to ::operator new[], which would then throw a
+ // std::bad_alloc, causing the test to fail.
+ __cxxabiv1::__cxa_throw_bad_array_new_length();
+ } catch ( const std::bad_array_new_length &banl ) {
+ return true;
+ }
+ return false;
+}
+
+int main(int argc, char *argv []) {
+ int ret_val = 0;
+
+ if ( !bad_array_new_length_test ()) {
+ std::cerr << "Bad array new length test failed!" << std::endl;
+ ret_val = 1;
+ }
+
+ return ret_val;
+}
More information about the cfe-commits
mailing list