blob: 3f333309dd8f1a44e0a5cff957193c601347dcaf [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
10#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 */
Eric Fiselier1285e4d2017-01-03 01:18:4817#if !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) && \
18 (defined(LIBCXX_BUILDING_LIBCXXABI) || defined(__APPLE__) || defined(LIBCXXRT))
Howard Hinnantf95d9f02012-02-17 19:24:4219#include <cxxabi.h>
Richard Smith11ffde32012-04-19 01:36:1220#endif
Howard Hinnant3e519522010-05-11 19:42:1621
Joerg Sonnenbergera1fbf342014-04-30 19:54:1122static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char *), "");
Howard Hinnant3e519522010-05-11 19:42:1623
Eric Fiseliera6244092016-10-25 19:33:1424
Howard Hinnant3e519522010-05-11 19:42:1625namespace std // purposefully not using versioning namespace
26{
27
Joerg Sonnenbergera1fbf342014-04-30 19:54:1128logic_error::logic_error(const string& msg) : __imp_(msg.c_str())
Howard Hinnant3e519522010-05-11 19:42:1629{
Howard Hinnant3e519522010-05-11 19:42:1630}
31
Joerg Sonnenbergera1fbf342014-04-30 19:54:1132logic_error::logic_error(const char* msg) : __imp_(msg)
Howard Hinnant3e519522010-05-11 19:42:1633{
Howard Hinnant3e519522010-05-11 19:42:1634}
35
Joerg Sonnenbergera1fbf342014-04-30 19:54:1136logic_error::logic_error(const logic_error& le) _NOEXCEPT : __imp_(le.__imp_)
Howard Hinnant3e519522010-05-11 19:42:1637{
Howard Hinnant3e519522010-05-11 19:42:1638}
39
40logic_error&
Howard Hinnanta62f2892011-05-26 19:48:0141logic_error::operator=(const logic_error& le) _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:1642{
Joerg Sonnenbergera1fbf342014-04-30 19:54:1143 __imp_ = le.__imp_;
Howard Hinnant3e519522010-05-11 19:42:1644 return *this;
45}
46
Peter Collingbourne26dd09e2013-10-06 22:13:1947#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)
Howard Hinnantf95d9f02012-02-17 19:24:4248
Howard Hinnanta62f2892011-05-26 19:48:0149logic_error::~logic_error() _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:1650{
Howard Hinnant3e519522010-05-11 19:42:1651}
52
53const char*
Howard Hinnanta62f2892011-05-26 19:48:0154logic_error::what() const _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:1655{
Joerg Sonnenbergera1fbf342014-04-30 19:54:1156 return __imp_.c_str();
Howard Hinnant3e519522010-05-11 19:42:1657}
58
Howard Hinnantf95d9f02012-02-17 19:24:4259#endif
60
Joerg Sonnenbergera1fbf342014-04-30 19:54:1161runtime_error::runtime_error(const string& msg) : __imp_(msg.c_str())
Howard Hinnant3e519522010-05-11 19:42:1662{
Howard Hinnant3e519522010-05-11 19:42:1663}
64
Joerg Sonnenbergera1fbf342014-04-30 19:54:1165runtime_error::runtime_error(const char* msg) : __imp_(msg)
Howard Hinnant3e519522010-05-11 19:42:1666{
Howard Hinnant3e519522010-05-11 19:42:1667}
68
Howard Hinnanta62f2892011-05-26 19:48:0169runtime_error::runtime_error(const runtime_error& le) _NOEXCEPT
Joerg Sonnenbergera1fbf342014-04-30 19:54:1170 : __imp_(le.__imp_)
Howard Hinnant3e519522010-05-11 19:42:1671{
Howard Hinnant3e519522010-05-11 19:42:1672}
73
74runtime_error&
Howard Hinnanta62f2892011-05-26 19:48:0175runtime_error::operator=(const runtime_error& le) _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:1676{
Joerg Sonnenbergera1fbf342014-04-30 19:54:1177 __imp_ = le.__imp_;
Howard Hinnant3e519522010-05-11 19:42:1678 return *this;
79}
80
Peter Collingbourne26dd09e2013-10-06 22:13:1981#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)
Howard Hinnantf95d9f02012-02-17 19:24:4282
Howard Hinnanta62f2892011-05-26 19:48:0183runtime_error::~runtime_error() _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:1684{
Howard Hinnant3e519522010-05-11 19:42:1685}
86
87const char*
Howard Hinnanta62f2892011-05-26 19:48:0188runtime_error::what() const _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:1689{
Joerg Sonnenbergera1fbf342014-04-30 19:54:1190 return __imp_.c_str();
Howard Hinnant3e519522010-05-11 19:42:1691}
92
Howard Hinnanta62f2892011-05-26 19:48:0193domain_error::~domain_error() _NOEXCEPT {}
94invalid_argument::~invalid_argument() _NOEXCEPT {}
95length_error::~length_error() _NOEXCEPT {}
96out_of_range::~out_of_range() _NOEXCEPT {}
Howard Hinnant3e519522010-05-11 19:42:1697
Howard Hinnanta62f2892011-05-26 19:48:0198range_error::~range_error() _NOEXCEPT {}
99overflow_error::~overflow_error() _NOEXCEPT {}
100underflow_error::~underflow_error() _NOEXCEPT {}
Howard Hinnant3e519522010-05-11 19:42:16101
Howard Hinnantf95d9f02012-02-17 19:24:42102#endif
103
Howard Hinnant3e519522010-05-11 19:42:16104} // std