blob: b4281209170cdc3a38a03039f9f2f7f3d97c94d9 [file] [log] [blame]
Nick Kledzik804b6e72010-05-14 20:19:37 +00001//===------------------------- typeinfo.cpp -------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Nick Kledzik804b6e72010-05-14 20:19:37 +00007//
8//===----------------------------------------------------------------------===//
9#include <stdlib.h>
Howard Hinnant8b5bb3c2012-07-26 17:42:39 +000010
11#ifndef __has_include
12#define __has_include(inc) 0
13#endif
14
Marshall Clowdece7fe2013-03-18 17:45:34 +000015#ifdef __APPLE__
Nick Kledzikc7e4d822010-09-10 20:42:36 +000016#include <cxxabi.h>
Howard Hinnant8b5bb3c2012-07-26 17:42:39 +000017#elif defined(LIBCXXRT) || __has_include(<cxxabi.h>)
18#include <cxxabi.h>
Howard Hinnant1348fba2010-10-02 23:23:25 +000019#endif
Nick Kledzik804b6e72010-05-14 20:19:37 +000020
21#include "typeinfo"
22
Peter Collingbourne8df03202013-10-03 22:04:10 +000023#if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION)
Howard Hinnantdea7f392012-02-02 20:48:35 +000024
Howard Hinnanted569212011-05-26 18:23:59 +000025std::bad_cast::bad_cast() _NOEXCEPT
Howard Hinnant16e6e1d2010-08-22 00:03:27 +000026{
Nick Kledzik804b6e72010-05-14 20:19:37 +000027}
28
Peter Collingbourne8df03202013-10-03 22:04:10 +000029std::bad_typeid::bad_typeid() _NOEXCEPT
30{
31}
32
33#ifndef __GLIBCXX__
34
Howard Hinnanted569212011-05-26 18:23:59 +000035std::bad_cast::~bad_cast() _NOEXCEPT
Howard Hinnant16e6e1d2010-08-22 00:03:27 +000036{
Nick Kledzik804b6e72010-05-14 20:19:37 +000037}
38
Howard Hinnant16e6e1d2010-08-22 00:03:27 +000039const char*
Howard Hinnanted569212011-05-26 18:23:59 +000040std::bad_cast::what() const _NOEXCEPT
Nick Kledzik804b6e72010-05-14 20:19:37 +000041{
42 return "std::bad_cast";
43}
44
Howard Hinnanted569212011-05-26 18:23:59 +000045std::bad_typeid::~bad_typeid() _NOEXCEPT
Howard Hinnant16e6e1d2010-08-22 00:03:27 +000046{
47}
48
49const char*
Howard Hinnanted569212011-05-26 18:23:59 +000050std::bad_typeid::what() const _NOEXCEPT
Nick Kledzik804b6e72010-05-14 20:19:37 +000051{
52 return "std::bad_typeid";
53}
Nick Kledzikc7e4d822010-09-10 20:42:36 +000054
Marshall Clowdece7fe2013-03-18 17:45:34 +000055#ifdef __APPLE__
Nick Kledzikc7e4d822010-09-10 20:42:36 +000056 // 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 Hinnantdb4d4782013-03-28 18:56:26 +000058 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 Kledzikc7e4d822010-09-10 20:42:36 +000070#endif
71
Peter Collingbourne8df03202013-10-03 22:04:10 +000072#endif // !__GLIBCXX__
73#endif // !LIBCXXRT && !_LIBCPPABI_VERSION