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