blob: aff4b1850d36bbb78f0089ffaba873d8a7335730 [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
Howard Hinnant49713b42012-09-03 18:13:1116#ifndef __has_include
17#define __has_include(inc) 0
18#endif
19
Joerg Sonnenbergera1fbf342014-04-30 19:54:1120/* For _LIBCPPABI_VERSION */
21#if __has_include(<cxxabi.h>) || defined(__APPLE_) || defined(LIBCXXRT)
Howard Hinnantf95d9f02012-02-17 19:24:4222#include <cxxabi.h>
Richard Smith11ffde32012-04-19 01:36:1223#endif
Howard Hinnant3e519522010-05-11 19:42:1624
Joerg Sonnenbergera1fbf342014-04-30 19:54:1125static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char *), "");
Howard Hinnant3e519522010-05-11 19:42:1626
27namespace std // purposefully not using versioning namespace
28{
29
Joerg Sonnenbergera1fbf342014-04-30 19:54:1130logic_error::logic_error(const string& msg) : __imp_(msg.c_str())
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 char* msg) : __imp_(msg)
Howard Hinnant3e519522010-05-11 19:42:1635{
Howard Hinnant3e519522010-05-11 19:42:1636}
37
Joerg Sonnenbergera1fbf342014-04-30 19:54:1138logic_error::logic_error(const logic_error& le) _NOEXCEPT : __imp_(le.__imp_)
Howard Hinnant3e519522010-05-11 19:42:1639{
Howard Hinnant3e519522010-05-11 19:42:1640}
41
42logic_error&
Howard Hinnanta62f2892011-05-26 19:48:0143logic_error::operator=(const logic_error& le) _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:1644{
Joerg Sonnenbergera1fbf342014-04-30 19:54:1145 __imp_ = le.__imp_;
Howard Hinnant3e519522010-05-11 19:42:1646 return *this;
47}
48
Peter Collingbourne26dd09e2013-10-06 22:13:1949#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)
Howard Hinnantf95d9f02012-02-17 19:24:4250
Howard Hinnanta62f2892011-05-26 19:48:0151logic_error::~logic_error() _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:1652{
Howard Hinnant3e519522010-05-11 19:42:1653}
54
55const char*
Howard Hinnanta62f2892011-05-26 19:48:0156logic_error::what() const _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:1657{
Joerg Sonnenbergera1fbf342014-04-30 19:54:1158 return __imp_.c_str();
Howard Hinnant3e519522010-05-11 19:42:1659}
60
Howard Hinnantf95d9f02012-02-17 19:24:4261#endif
62
Joerg Sonnenbergera1fbf342014-04-30 19:54:1163runtime_error::runtime_error(const string& msg) : __imp_(msg.c_str())
Howard Hinnant3e519522010-05-11 19:42:1664{
Howard Hinnant3e519522010-05-11 19:42:1665}
66
Joerg Sonnenbergera1fbf342014-04-30 19:54:1167runtime_error::runtime_error(const char* msg) : __imp_(msg)
Howard Hinnant3e519522010-05-11 19:42:1668{
Howard Hinnant3e519522010-05-11 19:42:1669}
70
Howard Hinnanta62f2892011-05-26 19:48:0171runtime_error::runtime_error(const runtime_error& le) _NOEXCEPT
Joerg Sonnenbergera1fbf342014-04-30 19:54:1172 : __imp_(le.__imp_)
Howard Hinnant3e519522010-05-11 19:42:1673{
Howard Hinnant3e519522010-05-11 19:42:1674}
75
76runtime_error&
Howard Hinnanta62f2892011-05-26 19:48:0177runtime_error::operator=(const runtime_error& le) _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:1678{
Joerg Sonnenbergera1fbf342014-04-30 19:54:1179 __imp_ = le.__imp_;
Howard Hinnant3e519522010-05-11 19:42:1680 return *this;
81}
82
Peter Collingbourne26dd09e2013-10-06 22:13:1983#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX)
Howard Hinnantf95d9f02012-02-17 19:24:4284
Howard Hinnanta62f2892011-05-26 19:48:0185runtime_error::~runtime_error() _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:1686{
Howard Hinnant3e519522010-05-11 19:42:1687}
88
89const char*
Howard Hinnanta62f2892011-05-26 19:48:0190runtime_error::what() const _NOEXCEPT
Howard Hinnant3e519522010-05-11 19:42:1691{
Joerg Sonnenbergera1fbf342014-04-30 19:54:1192 return __imp_.c_str();
Howard Hinnant3e519522010-05-11 19:42:1693}
94
Howard Hinnanta62f2892011-05-26 19:48:0195domain_error::~domain_error() _NOEXCEPT {}
96invalid_argument::~invalid_argument() _NOEXCEPT {}
97length_error::~length_error() _NOEXCEPT {}
98out_of_range::~out_of_range() _NOEXCEPT {}
Howard Hinnant3e519522010-05-11 19:42:1699
Howard Hinnanta62f2892011-05-26 19:48:01100range_error::~range_error() _NOEXCEPT {}
101overflow_error::~overflow_error() _NOEXCEPT {}
102underflow_error::~underflow_error() _NOEXCEPT {}
Howard Hinnant3e519522010-05-11 19:42:16103
Howard Hinnantf95d9f02012-02-17 19:24:42104#endif
105
Howard Hinnant3e519522010-05-11 19:42:16106} // std