Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===------------------------ stdexcept.cpp -------------------------------===// |
2 | // | ||||
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
6 | // Source Licenses. See LICENSE.TXT for details. | ||||
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
8 | //===----------------------------------------------------------------------===// | ||||
9 | |||||
10 | #include "stdexcept" | ||||
11 | #include "new" | ||||
12 | #include "string" | ||||
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 13 | #include "system_error" |
Eric Fiselier | 12f2b26 | 2017-07-12 01:38:35 +0000 | [diff] [blame] | 14 | #include "include/refstring.h" |
Richard Smith | c756f5b | 2012-04-19 01:36:12 +0000 | [diff] [blame] | 15 | |
Joerg Sonnenberger | 5562207 | 2014-04-30 19:54:11 +0000 | [diff] [blame] | 16 | /* For _LIBCPPABI_VERSION */ |
Eric Fiselier | cfc5515 | 2017-01-03 01:18:48 +0000 | [diff] [blame] | 17 | #if !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) && \ |
18 | (defined(LIBCXX_BUILDING_LIBCXXABI) || defined(__APPLE__) || defined(LIBCXXRT)) | ||||
Howard Hinnant | e1642e1 | 2012-02-17 19:24:42 +0000 | [diff] [blame] | 19 | #include <cxxabi.h> |
Richard Smith | c756f5b | 2012-04-19 01:36:12 +0000 | [diff] [blame] | 20 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 21 | |
Joerg Sonnenberger | 5562207 | 2014-04-30 19:54:11 +0000 | [diff] [blame] | 22 | static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char *), ""); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 23 | |
Eric Fiselier | 6979a42 | 2016-10-25 19:33:14 +0000 | [diff] [blame] | 24 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 25 | namespace std // purposefully not using versioning namespace |
26 | { | ||||
27 | |||||
Joerg Sonnenberger | 5562207 | 2014-04-30 19:54:11 +0000 | [diff] [blame] | 28 | logic_error::logic_error(const string& msg) : __imp_(msg.c_str()) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 29 | { |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 30 | } |
31 | |||||
Joerg Sonnenberger | 5562207 | 2014-04-30 19:54:11 +0000 | [diff] [blame] | 32 | logic_error::logic_error(const char* msg) : __imp_(msg) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 33 | { |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 34 | } |
35 | |||||
Joerg Sonnenberger | 5562207 | 2014-04-30 19:54:11 +0000 | [diff] [blame] | 36 | logic_error::logic_error(const logic_error& le) _NOEXCEPT : __imp_(le.__imp_) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 37 | { |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 38 | } |
39 | |||||
40 | logic_error& | ||||
Howard Hinnant | 1e15fd1 | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 41 | logic_error::operator=(const logic_error& le) _NOEXCEPT |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 42 | { |
Joerg Sonnenberger | 5562207 | 2014-04-30 19:54:11 +0000 | [diff] [blame] | 43 | __imp_ = le.__imp_; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 44 | return *this; |
45 | } | ||||
46 | |||||
Peter Collingbourne | d0d308f | 2013-10-06 22:13:19 +0000 | [diff] [blame] | 47 | #if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX) |
Howard Hinnant | e1642e1 | 2012-02-17 19:24:42 +0000 | [diff] [blame] | 48 | |
Howard Hinnant | 1e15fd1 | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 49 | logic_error::~logic_error() _NOEXCEPT |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 50 | { |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 51 | } |
52 | |||||
53 | const char* | ||||
Howard Hinnant | 1e15fd1 | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 54 | logic_error::what() const _NOEXCEPT |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 55 | { |
Joerg Sonnenberger | 5562207 | 2014-04-30 19:54:11 +0000 | [diff] [blame] | 56 | return __imp_.c_str(); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 57 | } |
58 | |||||
Howard Hinnant | e1642e1 | 2012-02-17 19:24:42 +0000 | [diff] [blame] | 59 | #endif |
60 | |||||
Joerg Sonnenberger | 5562207 | 2014-04-30 19:54:11 +0000 | [diff] [blame] | 61 | runtime_error::runtime_error(const string& msg) : __imp_(msg.c_str()) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 62 | { |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 63 | } |
64 | |||||
Joerg Sonnenberger | 5562207 | 2014-04-30 19:54:11 +0000 | [diff] [blame] | 65 | runtime_error::runtime_error(const char* msg) : __imp_(msg) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 66 | { |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 67 | } |
68 | |||||
Howard Hinnant | 1e15fd1 | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 69 | runtime_error::runtime_error(const runtime_error& le) _NOEXCEPT |
Joerg Sonnenberger | 5562207 | 2014-04-30 19:54:11 +0000 | [diff] [blame] | 70 | : __imp_(le.__imp_) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 71 | { |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 72 | } |
73 | |||||
74 | runtime_error& | ||||
Howard Hinnant | 1e15fd1 | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 75 | runtime_error::operator=(const runtime_error& le) _NOEXCEPT |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 76 | { |
Joerg Sonnenberger | 5562207 | 2014-04-30 19:54:11 +0000 | [diff] [blame] | 77 | __imp_ = le.__imp_; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 78 | return *this; |
79 | } | ||||
80 | |||||
Peter Collingbourne | d0d308f | 2013-10-06 22:13:19 +0000 | [diff] [blame] | 81 | #if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX) |
Howard Hinnant | e1642e1 | 2012-02-17 19:24:42 +0000 | [diff] [blame] | 82 | |
Howard Hinnant | 1e15fd1 | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 83 | runtime_error::~runtime_error() _NOEXCEPT |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 84 | { |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 85 | } |
86 | |||||
87 | const char* | ||||
Howard Hinnant | 1e15fd1 | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 88 | runtime_error::what() const _NOEXCEPT |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 89 | { |
Joerg Sonnenberger | 5562207 | 2014-04-30 19:54:11 +0000 | [diff] [blame] | 90 | return __imp_.c_str(); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 91 | } |
92 | |||||
Howard Hinnant | 1e15fd1 | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 93 | domain_error::~domain_error() _NOEXCEPT {} |
94 | invalid_argument::~invalid_argument() _NOEXCEPT {} | ||||
95 | length_error::~length_error() _NOEXCEPT {} | ||||
96 | out_of_range::~out_of_range() _NOEXCEPT {} | ||||
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 97 | |
Howard Hinnant | 1e15fd1 | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 98 | range_error::~range_error() _NOEXCEPT {} |
99 | overflow_error::~overflow_error() _NOEXCEPT {} | ||||
100 | underflow_error::~underflow_error() _NOEXCEPT {} | ||||
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 101 | |
Howard Hinnant | e1642e1 | 2012-02-17 19:24:42 +0000 | [diff] [blame] | 102 | #endif |
103 | |||||
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 104 | } // std |