blob: 90d8a34b82debcab3eb854801734d062205404dc [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:161//===------------------------ stdexcept.cpp -------------------------------===//
2//
Howard Hinnant5b08a8a2010-05-11 21:36:013// The LLVM Compiler Infrastructure
Howard Hinnant3e519522010-05-11 19:42:164//
Howard Hinnant412dbeb2010-11-16 22:09:025// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnant3e519522010-05-11 19:42:167//
8//===----------------------------------------------------------------------===//
9
Howard Hinnant3e519522010-05-11 19:42:1610#include "stdexcept"
11#include "new"
12#include "string"
Howard Hinnant3e519522010-05-11 19:42:1613#include "system_error"
Eric Fiseliera6244092016-10-25 19:33:1414#include "__refstring"
Richard Smith11ffde32012-04-19 01:36:1215
Joerg Sonnenbergera1fbf342014-04-30 19:54:1116/* For _LIBCPPABI_VERSION */
Benjamin Kramer02adf402015-10-16 11:26:2617#if 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