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