]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/libc++/src/typeinfo.cpp
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.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 #ifndef __has_include
12 #define __has_include(inc) 0
13 #endif
14
15 #ifdef __APPLE__
16 #include <cxxabi.h>
17 #elif defined(LIBCXXRT) || __has_include(<cxxabi.h>)
18 #include <cxxabi.h>
19 #endif
20
21 #include "typeinfo"
22
23 #if !(defined(_LIBCPPABI_VERSION) || defined(LIBCXXRT))
24
25 std::bad_cast::bad_cast() _NOEXCEPT
26 {
27 }
28
29 std::bad_cast::~bad_cast() _NOEXCEPT
30 {
31 }
32
33 const char*
34 std::bad_cast::what() const _NOEXCEPT
35 {
36   return "std::bad_cast";
37 }
38
39 std::bad_typeid::bad_typeid() _NOEXCEPT
40 {
41 }
42
43 std::bad_typeid::~bad_typeid() _NOEXCEPT
44 {
45 }
46
47 const char*
48 std::bad_typeid::what() const _NOEXCEPT
49 {
50   return "std::bad_typeid";
51 }
52
53 #ifdef __APPLE__
54   // On Darwin, the cxa_bad_* functions cannot be in the lower level library
55   // because bad_cast and bad_typeid are defined in his higher level library
56   void __cxxabiv1::__cxa_bad_typeid()
57   {
58 #ifndef _LIBCPP_NO_EXCEPTIONS
59      throw std::bad_typeid();
60 #endif
61   }
62   void __cxxabiv1::__cxa_bad_cast()
63   {
64 #ifndef _LIBCPP_NO_EXCEPTIONS
65       throw std::bad_cast();
66 #endif
67   }
68 #endif
69
70 #endif  // _LIBCPPABI_VERSION