1//===------------------------ stdexcept.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
10#include "__refstring"
11#include "stdexcept"
12#include "new"
13#include "string"
14#include "system_error"
15
16#ifndef __has_include
17#ifdef LIBCXXABI
18#define __has_include(inc) 1
19#else
20#define __has_include(inc) 0
21#endif
22#endif
23
24/* For _LIBCPPABI_VERSION */
25#if __has_include(<cxxabi.h>) || defined(__APPLE_) || defined(LIBCXXRT)
26#include <cxxabi.h>
27#endif
28
29static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char *), "");
30
31namespace std  // purposefully not using versioning namespace
32{
33
34logic_error::logic_error(const string& msg) : __imp_(msg.c_str())
35{
36}
37
38logic_error::logic_error(const char* msg) : __imp_(msg)
39{
40}
41
42logic_error::logic_error(const logic_error& le) _NOEXCEPT : __imp_(le.__imp_)
43{
44}
45
46logic_error&
47logic_error::operator=(const logic_error& le) _NOEXCEPT
48{
49    __imp_ = le.__imp_;
50    return *this;
51}
52
53#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)
54
55logic_error::~logic_error() _NOEXCEPT
56{
57}
58
59const char*
60logic_error::what() const _NOEXCEPT
61{
62    return __imp_.c_str();
63}
64
65#endif
66
67runtime_error::runtime_error(const string& msg) : __imp_(msg.c_str())
68{
69}
70
71runtime_error::runtime_error(const char* msg) : __imp_(msg)
72{
73}
74
75runtime_error::runtime_error(const runtime_error& le) _NOEXCEPT
76  : __imp_(le.__imp_)
77{
78}
79
80runtime_error&
81runtime_error::operator=(const runtime_error& le) _NOEXCEPT
82{
83    __imp_ = le.__imp_;
84    return *this;
85}
86
87#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)
88
89runtime_error::~runtime_error() _NOEXCEPT
90{
91}
92
93const char*
94runtime_error::what() const _NOEXCEPT
95{
96    return __imp_.c_str();
97}
98
99domain_error::~domain_error() _NOEXCEPT {}
100invalid_argument::~invalid_argument() _NOEXCEPT {}
101length_error::~length_error() _NOEXCEPT {}
102out_of_range::~out_of_range() _NOEXCEPT {}
103
104range_error::~range_error() _NOEXCEPT {}
105overflow_error::~overflow_error() _NOEXCEPT {}
106underflow_error::~underflow_error() _NOEXCEPT {}
107
108#endif
109
110}  // std
111