Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 1 | //===------------------------- typeinfo.cpp -------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | #include <stdlib.h> |
Howard Hinnant | 8b5bb3c | 2012-07-26 17:42:39 +0000 | [diff] [blame] | 10 | |
| 11 | #ifndef __has_include |
| 12 | #define __has_include(inc) 0 |
| 13 | #endif |
| 14 | |
Marshall Clow | dece7fe | 2013-03-18 17:45:34 +0000 | [diff] [blame] | 15 | #ifdef __APPLE__ |
Nick Kledzik | c7e4d82 | 2010-09-10 20:42:36 +0000 | [diff] [blame] | 16 | #include <cxxabi.h> |
Howard Hinnant | 8b5bb3c | 2012-07-26 17:42:39 +0000 | [diff] [blame] | 17 | #elif defined(LIBCXXRT) || __has_include(<cxxabi.h>) |
| 18 | #include <cxxabi.h> |
Howard Hinnant | 1348fba | 2010-10-02 23:23:25 +0000 | [diff] [blame] | 19 | #endif |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 20 | |
| 21 | #include "typeinfo" |
| 22 | |
Peter Collingbourne | 8df0320 | 2013-10-03 22:04:10 +0000 | [diff] [blame] | 23 | #if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION) |
Howard Hinnant | dea7f39 | 2012-02-02 20:48:35 +0000 | [diff] [blame] | 24 | |
Howard Hinnant | ed56921 | 2011-05-26 18:23:59 +0000 | [diff] [blame] | 25 | std::bad_cast::bad_cast() _NOEXCEPT |
Howard Hinnant | 16e6e1d | 2010-08-22 00:03:27 +0000 | [diff] [blame] | 26 | { |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 27 | } |
| 28 | |
Peter Collingbourne | 8df0320 | 2013-10-03 22:04:10 +0000 | [diff] [blame] | 29 | std::bad_typeid::bad_typeid() _NOEXCEPT |
| 30 | { |
| 31 | } |
| 32 | |
| 33 | #ifndef __GLIBCXX__ |
| 34 | |
Howard Hinnant | ed56921 | 2011-05-26 18:23:59 +0000 | [diff] [blame] | 35 | std::bad_cast::~bad_cast() _NOEXCEPT |
Howard Hinnant | 16e6e1d | 2010-08-22 00:03:27 +0000 | [diff] [blame] | 36 | { |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 37 | } |
| 38 | |
Howard Hinnant | 16e6e1d | 2010-08-22 00:03:27 +0000 | [diff] [blame] | 39 | const char* |
Howard Hinnant | ed56921 | 2011-05-26 18:23:59 +0000 | [diff] [blame] | 40 | std::bad_cast::what() const _NOEXCEPT |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 41 | { |
| 42 | return "std::bad_cast"; |
| 43 | } |
| 44 | |
Howard Hinnant | ed56921 | 2011-05-26 18:23:59 +0000 | [diff] [blame] | 45 | std::bad_typeid::~bad_typeid() _NOEXCEPT |
Howard Hinnant | 16e6e1d | 2010-08-22 00:03:27 +0000 | [diff] [blame] | 46 | { |
| 47 | } |
| 48 | |
| 49 | const char* |
Howard Hinnant | ed56921 | 2011-05-26 18:23:59 +0000 | [diff] [blame] | 50 | std::bad_typeid::what() const _NOEXCEPT |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 51 | { |
| 52 | return "std::bad_typeid"; |
| 53 | } |
Nick Kledzik | c7e4d82 | 2010-09-10 20:42:36 +0000 | [diff] [blame] | 54 | |
Marshall Clow | dece7fe | 2013-03-18 17:45:34 +0000 | [diff] [blame] | 55 | #ifdef __APPLE__ |
Nick Kledzik | c7e4d82 | 2010-09-10 20:42:36 +0000 | [diff] [blame] | 56 | // On Darwin, the cxa_bad_* functions cannot be in the lower level library |
| 57 | // because bad_cast and bad_typeid are defined in his higher level library |
Howard Hinnant | db4d478 | 2013-03-28 18:56:26 +0000 | [diff] [blame] | 58 | void __cxxabiv1::__cxa_bad_typeid() |
| 59 | { |
| 60 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 61 | throw std::bad_typeid(); |
| 62 | #endif |
| 63 | } |
| 64 | void __cxxabiv1::__cxa_bad_cast() |
| 65 | { |
| 66 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 67 | throw std::bad_cast(); |
| 68 | #endif |
| 69 | } |
Nick Kledzik | c7e4d82 | 2010-09-10 20:42:36 +0000 | [diff] [blame] | 70 | #endif |
| 71 | |
Peter Collingbourne | 8df0320 | 2013-10-03 22:04:10 +0000 | [diff] [blame] | 72 | #endif // !__GLIBCXX__ |
| 73 | #endif // !LIBCXXRT && !_LIBCPPABI_VERSION |