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