]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/libc++/src/typeinfo.cpp
Revert and redo r306083.
[FreeBSD/FreeBSD.git] / contrib / libc++ / src / typeinfo.cpp
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
20 std::bad_cast::bad_cast() _NOEXCEPT
21 {
22 }
23
24 std::bad_typeid::bad_typeid() _NOEXCEPT
25 {
26 }
27
28 #ifndef __GLIBCXX__
29
30 std::bad_cast::~bad_cast() _NOEXCEPT
31 {
32 }
33
34 const char*
35 std::bad_cast::what() const _NOEXCEPT
36 {
37   return "std::bad_cast";
38 }
39
40 std::bad_typeid::~bad_typeid() _NOEXCEPT
41 {
42 }
43
44 const char*
45 std::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