blob: 6ae35feedaf65c13fbda1ae9faa93b2c4a9b1c99 [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:161//===------------------------ stdexcept.cpp -------------------------------===//
2//
Chandler Carruth57b08b02019-01-19 10:56:403// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Howard Hinnant3e519522010-05-11 19:42:166//
7//===----------------------------------------------------------------------===//
8
9#include "stdexcept"
10#include "new"
11#include "string"
Howard Hinnant3e519522010-05-11 19:42:1612#include "system_error"
Eric Fiseliere3e7c0f2017-07-12 01:38:3513#include "include/refstring.h"
Richard Smith11ffde32012-04-19 01:36:1214
Joerg Sonnenbergera1fbf342014-04-30 19:54:1115/* For _LIBCPPABI_VERSION */
Eric Fiselier1285e4d2017-01-03 01:18:4816#if !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) && \
17 (defined(LIBCXX_BUILDING_LIBCXXABI) || defined(__APPLE__) || defined(LIBCXXRT))
Howard Hinnantf95d9f02012-02-17 19:24:4218#include <cxxabi.h>
Richard Smith11ffde32012-04-19 01:36:1219#endif
Howard Hinnant3e519522010-05-11 19:42:1620
Joerg Sonnenbergera1fbf342014-04-30 19:54:1121static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char *), "");
Howard Hinnant3e519522010-05-11 19:42:1622
Eric Fiseliera6244092016-10-25 19:33:1423
Howard Hinnant3e519522010-05-11 19:42:1624namespace std // purposefully not using versioning namespace
25{
26
Joerg Sonnenbergera1fbf342014-04-30 19:54:1127logic_error::logic_error(const string& msg) : __imp_(msg.c_str())
Howard Hinnant3e519522010-05-11 19:42:1628{
Howard Hinnant3e519522010-05-11 19:42:1629}
30
Joerg Sonnenbergera1fbf342014-04-30 19:54:1131logic_error::logic_error(const char* msg) : __imp_(msg)
Howard Hinnant3e519522010-05-11 19:42:1632{
Howard Hinnant3e519522010-05-11 19:42:1633}
34
Joerg Sonnenbergera1fbf342014-04-30 19:54:1135logic_error::logic_error(const logic_error& le) _NOEXCEPT : __imp_(le.__imp_)
Howard Hinnant3e519522010-05-11 19:42:1636{
Howard Hinnant3e519522010-05-11 19:42:1637}
38
39logic_error&
Howard Hinnanta62f2892011-05-26 19:48:0140logic_error::operator=(const logic_error& le) _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:1641{
Joerg Sonnenbergera1fbf342014-04-30 19:54:1142 __imp_ = le.__imp_;
Howard Hinnant3e519522010-05-11 19:42:1643 return *this;
44}
45
Peter Collingbourne26dd09e2013-10-06 22:13:1946#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)
Howard Hinnantf95d9f02012-02-17 19:24:4247
Howard Hinnanta62f2892011-05-26 19:48:0148logic_error::~logic_error() _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:1649{
Howard Hinnant3e519522010-05-11 19:42:1650}
51
52const char*
Howard Hinnanta62f2892011-05-26 19:48:0153logic_error::what() const _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:1654{
Joerg Sonnenbergera1fbf342014-04-30 19:54:1155 return __imp_.c_str();
Howard Hinnant3e519522010-05-11 19:42:1656}
57
Howard Hinnantf95d9f02012-02-17 19:24:4258#endif
59
Joerg Sonnenbergera1fbf342014-04-30 19:54:1160runtime_error::runtime_error(const string& msg) : __imp_(msg.c_str())
Howard Hinnant3e519522010-05-11 19:42:1661{
Howard Hinnant3e519522010-05-11 19:42:1662}
63
Joerg Sonnenbergera1fbf342014-04-30 19:54:1164runtime_error::runtime_error(const char* msg) : __imp_(msg)
Howard Hinnant3e519522010-05-11 19:42:1665{
Howard Hinnant3e519522010-05-11 19:42:1666}
67
Howard Hinnanta62f2892011-05-26 19:48:0168runtime_error::runtime_error(const runtime_error& le) _NOEXCEPT
Joerg Sonnenbergera1fbf342014-04-30 19:54:1169 : __imp_(le.__imp_)
Howard Hinnant3e519522010-05-11 19:42:1670{
Howard Hinnant3e519522010-05-11 19:42:1671}
72
73runtime_error&
Howard Hinnanta62f2892011-05-26 19:48:0174runtime_error::operator=(const runtime_error& le) _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:1675{
Joerg Sonnenbergera1fbf342014-04-30 19:54:1176 __imp_ = le.__imp_;
Howard Hinnant3e519522010-05-11 19:42:1677 return *this;
78}
79
Peter Collingbourne26dd09e2013-10-06 22:13:1980#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)
Howard Hinnantf95d9f02012-02-17 19:24:4281
Howard Hinnanta62f2892011-05-26 19:48:0182runtime_error::~runtime_error() _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:1683{
Howard Hinnant3e519522010-05-11 19:42:1684}
85
86const char*
Howard Hinnanta62f2892011-05-26 19:48:0187runtime_error::what() const _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:1688{
Joerg Sonnenbergera1fbf342014-04-30 19:54:1189 return __imp_.c_str();
Howard Hinnant3e519522010-05-11 19:42:1690}
91
Howard Hinnanta62f2892011-05-26 19:48:0192domain_error::~domain_error() _NOEXCEPT {}
93invalid_argument::~invalid_argument() _NOEXCEPT {}
94length_error::~length_error() _NOEXCEPT {}
95out_of_range::~out_of_range() _NOEXCEPT {}
Howard Hinnant3e519522010-05-11 19:42:1696
Howard Hinnanta62f2892011-05-26 19:48:0197range_error::~range_error() _NOEXCEPT {}
98overflow_error::~overflow_error() _NOEXCEPT {}
99underflow_error::~underflow_error() _NOEXCEPT {}
Howard Hinnant3e519522010-05-11 19:42:16100
Howard Hinnantf95d9f02012-02-17 19:24:42101#endif
102
Howard Hinnant3e519522010-05-11 19:42:16103} // std