1 //===------------------------ stdexcept.cpp -------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "stdexcept" 10 #include "new" 11 #include "string" 12 #include "system_error" 13 #include "include/refstring.h" 14 15 /* For _LIBCPPABI_VERSION */ 16 #if !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) && \ 17 (defined(LIBCXX_BUILDING_LIBCXXABI) || defined(__APPLE__) || defined(LIBCXXRT)) 18 #include <cxxabi.h> 19 #endif 20 21 static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char *), ""); 22 23 24 namespace std // purposefully not using versioning namespace 25 { 26 27 logic_error::logic_error(const string& msg) : __imp_(msg.c_str()) 28 { 29 } 30 31 logic_error::logic_error(const char* msg) : __imp_(msg) 32 { 33 } 34 35 logic_error::logic_error(const logic_error& le) _NOEXCEPT : __imp_(le.__imp_) 36 { 37 } 38 39 logic_error& 40 logic_error::operator=(const logic_error& le) _NOEXCEPT 41 { 42 __imp_ = le.__imp_; 43 return *this; 44 } 45 46 runtime_error::runtime_error(const string& msg) : __imp_(msg.c_str()) 47 { 48 } 49 50 runtime_error::runtime_error(const char* msg) : __imp_(msg) 51 { 52 } 53 54 runtime_error::runtime_error(const runtime_error& le) _NOEXCEPT 55 : __imp_(le.__imp_) 56 { 57 } 58 59 runtime_error& 60 runtime_error::operator=(const runtime_error& le) _NOEXCEPT 61 { 62 __imp_ = le.__imp_; 63 return *this; 64 } 65 66 #if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX) 67 68 const char* 69 logic_error::what() const _NOEXCEPT 70 { 71 return __imp_.c_str(); 72 } 73 74 const char* 75 runtime_error::what() const _NOEXCEPT 76 { 77 return __imp_.c_str(); 78 } 79 80 #if !defined(_LIBCPP_ABI_VCRUNTIME) 81 82 logic_error::~logic_error() _NOEXCEPT {} 83 domain_error::~domain_error() _NOEXCEPT {} 84 invalid_argument::~invalid_argument() _NOEXCEPT {} 85 length_error::~length_error() _NOEXCEPT {} 86 out_of_range::~out_of_range() _NOEXCEPT {} 87 88 runtime_error::~runtime_error() _NOEXCEPT {} 89 range_error::~range_error() _NOEXCEPT {} 90 overflow_error::~overflow_error() _NOEXCEPT {} 91 underflow_error::~underflow_error() _NOEXCEPT {} 92 93 #endif 94 #endif 95 96 } // std 97