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