blob: 60828944a1bc860b9b501ab69b960d5ee482c037 [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
David Chisnall1e8b3f92012-02-29 12:59:17 +000023#if !(defined(_LIBCPPABI_VERSION) || defined(LIBCXXRT))
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
Howard Hinnanted569212011-05-26 18:23:59 +000029std::bad_cast::~bad_cast() _NOEXCEPT
Howard Hinnant16e6e1d2010-08-22 00:03:27 +000030{
Nick Kledzik804b6e72010-05-14 20:19:37 +000031}
32
Howard Hinnant16e6e1d2010-08-22 00:03:27 +000033const char*
Howard Hinnanted569212011-05-26 18:23:59 +000034std::bad_cast::what() const _NOEXCEPT
Nick Kledzik804b6e72010-05-14 20:19:37 +000035{
36 return "std::bad_cast";
37}
38
Howard Hinnanted569212011-05-26 18:23:59 +000039std::bad_typeid::bad_typeid() _NOEXCEPT
Nick Kledzik804b6e72010-05-14 20:19:37 +000040{
41}
42
Howard Hinnanted569212011-05-26 18:23:59 +000043std::bad_typeid::~bad_typeid() _NOEXCEPT
Howard Hinnant16e6e1d2010-08-22 00:03:27 +000044{
45}
46
47const char*
Howard Hinnanted569212011-05-26 18:23:59 +000048std::bad_typeid::what() const _NOEXCEPT
Nick Kledzik804b6e72010-05-14 20:19:37 +000049{
50 return "std::bad_typeid";
51}
Nick Kledzikc7e4d822010-09-10 20:42:36 +000052
Marshall Clowdece7fe2013-03-18 17:45:34 +000053#ifdef __APPLE__
Nick Kledzikc7e4d822010-09-10 20:42:36 +000054 // 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
Howard Hinnantdb4d4782013-03-28 18:56:26 +000056 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 }
Nick Kledzikc7e4d822010-09-10 20:42:36 +000068#endif
69
Howard Hinnantdea7f392012-02-02 20:48:35 +000070#endif // _LIBCPPABI_VERSION