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(__APPLE__) || defined(LIBCXXRT) ||                                 \
12    defined(LIBCXX_BUILDING_LIBCXXABI)
13#include <cxxabi.h>
14#endif
15
16#include "typeinfo"
17
18#if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION)
19
20std::bad_cast::bad_cast() _NOEXCEPT
21{
22}
23
24std::bad_typeid::bad_typeid() _NOEXCEPT
25{
26}
27
28#ifndef __GLIBCXX__
29
30std::bad_cast::~bad_cast() _NOEXCEPT
31{
32}
33
34const char*
35std::bad_cast::what() const _NOEXCEPT
36{
37  return "std::bad_cast";
38}
39
40std::bad_typeid::~bad_typeid() _NOEXCEPT
41{
42}
43
44const char*
45std::bad_typeid::what() const _NOEXCEPT
46{
47  return "std::bad_typeid";
48}
49
50#ifdef __APPLE__
51  // On Darwin, the cxa_bad_* functions cannot be in the lower level library
52  // because bad_cast and bad_typeid are defined in his higher level library
53  void __cxxabiv1::__cxa_bad_typeid()
54  {
55#ifndef _LIBCPP_NO_EXCEPTIONS
56     throw std::bad_typeid();
57#endif
58  }
59  void __cxxabiv1::__cxa_bad_cast()
60  {
61#ifndef _LIBCPP_NO_EXCEPTIONS
62      throw std::bad_cast();
63#endif
64  }
65#endif
66
67#endif  // !__GLIBCXX__
68#endif  // !LIBCXXRT && !_LIBCPPABI_VERSION
69