blob: 0a08bfec27ec9a49549f7c3b01a3fdd47bb7cbed [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
Joerg Sonnenbergera1fbf342014-04-30 19:54:1110#include "__refstring"
Howard Hinnant3e519522010-05-11 19:42:1611#include "stdexcept"
12#include "new"
13#include "string"
Howard Hinnant3e519522010-05-11 19:42:1614#include "system_error"
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
23namespace std // purposefully not using versioning namespace
24{
25
Joerg Sonnenbergera1fbf342014-04-30 19:54:1126logic_error::logic_error(const string& msg) : __imp_(msg.c_str())
Howard Hinnant3e519522010-05-11 19:42:1627{
Howard Hinnant3e519522010-05-11 19:42:1628}
29
Joerg Sonnenbergera1fbf342014-04-30 19:54:1130logic_error::logic_error(const char* msg) : __imp_(msg)
Howard Hinnant3e519522010-05-11 19:42:1631{
Howard Hinnant3e519522010-05-11 19:42:1632}
33
Joerg Sonnenbergera1fbf342014-04-30 19:54:1134logic_error::logic_error(const logic_error& le) _NOEXCEPT : __imp_(le.__imp_)
Howard Hinnant3e519522010-05-11 19:42:1635{
Howard Hinnant3e519522010-05-11 19:42:1636}
37
38logic_error&
Howard Hinnanta62f2892011-05-26 19:48:0139logic_error::operator=(const logic_error& le) _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:1640{
Joerg Sonnenbergera1fbf342014-04-30 19:54:1141 __imp_ = le.__imp_;
Howard Hinnant3e519522010-05-11 19:42:1642 return *this;
43}
44
Peter Collingbourne26dd09e2013-10-06 22:13:1945#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)
Howard Hinnantf95d9f02012-02-17 19:24:4246
Howard Hinnanta62f2892011-05-26 19:48:0147logic_error::~logic_error() _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:1648{
Howard Hinnant3e519522010-05-11 19:42:1649}
50
51const char*
Howard Hinnanta62f2892011-05-26 19:48:0152logic_error::what() const _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:1653{
Joerg Sonnenbergera1fbf342014-04-30 19:54:1154 return __imp_.c_str();
Howard Hinnant3e519522010-05-11 19:42:1655}
56
Howard Hinnantf95d9f02012-02-17 19:24:4257#endif
58
Joerg Sonnenbergera1fbf342014-04-30 19:54:1159runtime_error::runtime_error(const string& msg) : __imp_(msg.c_str())
Howard Hinnant3e519522010-05-11 19:42:1660{
Howard Hinnant3e519522010-05-11 19:42:1661}
62
Joerg Sonnenbergera1fbf342014-04-30 19:54:1163runtime_error::runtime_error(const char* msg) : __imp_(msg)
Howard Hinnant3e519522010-05-11 19:42:1664{
Howard Hinnant3e519522010-05-11 19:42:1665}
66
Howard Hinnanta62f2892011-05-26 19:48:0167runtime_error::runtime_error(const runtime_error& le) _NOEXCEPT
Joerg Sonnenbergera1fbf342014-04-30 19:54:1168 : __imp_(le.__imp_)
Howard Hinnant3e519522010-05-11 19:42:1669{
Howard Hinnant3e519522010-05-11 19:42:1670}
71
72runtime_error&
Howard Hinnanta62f2892011-05-26 19:48:0173runtime_error::operator=(const runtime_error& le) _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:1674{
Joerg Sonnenbergera1fbf342014-04-30 19:54:1175 __imp_ = le.__imp_;
Howard Hinnant3e519522010-05-11 19:42:1676 return *this;
77}
78
Peter Collingbourne26dd09e2013-10-06 22:13:1979#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)
Howard Hinnantf95d9f02012-02-17 19:24:4280
Howard Hinnanta62f2892011-05-26 19:48:0181runtime_error::~runtime_error() _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:1682{
Howard Hinnant3e519522010-05-11 19:42:1683}
84
85const char*
Howard Hinnanta62f2892011-05-26 19:48:0186runtime_error::what() const _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:1687{
Joerg Sonnenbergera1fbf342014-04-30 19:54:1188 return __imp_.c_str();
Howard Hinnant3e519522010-05-11 19:42:1689}
90
Howard Hinnanta62f2892011-05-26 19:48:0191domain_error::~domain_error() _NOEXCEPT {}
92invalid_argument::~invalid_argument() _NOEXCEPT {}
93length_error::~length_error() _NOEXCEPT {}
94out_of_range::~out_of_range() _NOEXCEPT {}
Howard Hinnant3e519522010-05-11 19:42:1695
Howard Hinnanta62f2892011-05-26 19:48:0196range_error::~range_error() _NOEXCEPT {}
97overflow_error::~overflow_error() _NOEXCEPT {}
98underflow_error::~underflow_error() _NOEXCEPT {}
Howard Hinnant3e519522010-05-11 19:42:1699
Howard Hinnantf95d9f02012-02-17 19:24:42100#endif
101
Howard Hinnant3e519522010-05-11 19:42:16102} // std