1 //===------------------------- typeinfo.cpp -------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 #include <stdlib.h>
10 
11 #if !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) && \
12     (defined(__APPLE__) || defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI))
13 #include <cxxabi.h>
14 #endif
15 
16 #include "typeinfo"
17 
18 #if defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) || \
19     defined(_LIBCPP_ABI_MICROSOFT) // FIXME: This is a temporary workaround
20 std::type_info::~type_info()
21 {
22 }
23 #endif
24 
25 #if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION)
26 
27 std::bad_cast::bad_cast() _NOEXCEPT
28 {
29 }
30 
31 std::bad_typeid::bad_typeid() _NOEXCEPT
32 {
33 }
34 
35 #ifndef __GLIBCXX__
36 
37 std::bad_cast::~bad_cast() _NOEXCEPT
38 {
39 }
40 
41 const char*
42 std::bad_cast::what() const _NOEXCEPT
43 {
44   return "std::bad_cast";
45 }
46 
47 std::bad_typeid::~bad_typeid() _NOEXCEPT
48 {
49 }
50 
51 const char*
52 std::bad_typeid::what() const _NOEXCEPT
53 {
54   return "std::bad_typeid";
55 }
56 
57 #if defined(__APPLE__) && !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY)
58   // On Darwin, the cxa_bad_* functions cannot be in the lower level library
59   // because bad_cast and bad_typeid are defined in his higher level library
60   void __cxxabiv1::__cxa_bad_typeid()
61   {
62 #ifndef _LIBCPP_NO_EXCEPTIONS
63      throw std::bad_typeid();
64 #else
65      _VSTD::abort();
66 #endif
67   }
68   void __cxxabiv1::__cxa_bad_cast()
69   {
70 #ifndef _LIBCPP_NO_EXCEPTIONS
71       throw std::bad_cast();
72 #else
73       _VSTD::abort();
74 #endif
75   }
76 #endif
77 
78 #endif  // !__GLIBCXX__
79 #endif  // !LIBCXXRT && !_LIBCPPABI_VERSION
80