blob: 8c3751f0edb5c4b5386d7a3ba13b7c320567c503 [file] [log] [blame]
Marshall Clowad3dea02011-06-03 02:04:41 +00001//===------------------------ cxa_aux_runtime.cpp -------------------------===//
2//
Chandler Carruth57b08b02019-01-19 10:56:40 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Marshall Clowad3dea02011-06-03 02:04:41 +00006//
Howard Hinnant575498b2011-06-07 19:56:49 +00007//
8// This file implements the "Auxiliary Runtime APIs"
Jonathan Roelofsc5f7e6f2014-02-12 04:49:09 +00009// http://mentorembedded.github.io/cxx-abi/abi-eh.html#cxx-aux
Marshall Clowad3dea02011-06-03 02:04:41 +000010//===----------------------------------------------------------------------===//
11
12#include "cxxabi.h"
Aaron Ballmaneb7c1a62014-09-11 17:26:43 +000013#include <new>
Marshall Clowad3dea02011-06-03 02:04:41 +000014#include <typeinfo>
15
Saleem Abdulrasool242d67b2015-12-04 02:14:41 +000016namespace __cxxabiv1 {
17extern "C" {
Eric Fiselier71e32922017-03-01 02:23:54 +000018_LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_cast(void) {
Asiri Rathnayake57e446d2016-05-31 12:01:32 +000019#ifndef _LIBCXXABI_NO_EXCEPTIONS
Saleem Abdulrasool12315ed2015-12-04 02:14:58 +000020 throw std::bad_cast();
Asiri Rathnayake57e446d2016-05-31 12:01:32 +000021#else
22 std::terminate();
23#endif
Saleem Abdulrasool12315ed2015-12-04 02:14:58 +000024}
Marshall Clowad3dea02011-06-03 02:04:41 +000025
Eric Fiselier71e32922017-03-01 02:23:54 +000026_LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_typeid(void) {
Asiri Rathnayake57e446d2016-05-31 12:01:32 +000027#ifndef _LIBCXXABI_NO_EXCEPTIONS
Saleem Abdulrasool12315ed2015-12-04 02:14:58 +000028 throw std::bad_typeid();
Asiri Rathnayake57e446d2016-05-31 12:01:32 +000029#else
30 std::terminate();
31#endif
Saleem Abdulrasool12315ed2015-12-04 02:14:58 +000032}
Marshall Clowad3dea02011-06-03 02:04:41 +000033
Eric Fiselier71e32922017-03-01 02:23:54 +000034_LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void
Saleem Abdulrasool12315ed2015-12-04 02:14:58 +000035__cxa_throw_bad_array_new_length(void) {
Asiri Rathnayake57e446d2016-05-31 12:01:32 +000036#ifndef _LIBCXXABI_NO_EXCEPTIONS
Saleem Abdulrasool242d67b2015-12-04 02:14:41 +000037 throw std::bad_array_new_length();
Asiri Rathnayake57e446d2016-05-31 12:01:32 +000038#else
39 std::terminate();
40#endif
Aaron Ballmaneb7c1a62014-09-11 17:26:43 +000041}
Saleem Abdulrasool242d67b2015-12-04 02:14:41 +000042} // extern "C"
43} // abi