Index: include/stdexcept =================================================================== --- include/stdexcept +++ include/stdexcept @@ -54,6 +54,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD +#ifndef _LIBCPP_ABI_VCRUNTIME class _LIBCPP_HIDDEN __libcpp_refstring { const char* __imp_; @@ -67,6 +68,7 @@ const char* c_str() const _NOEXCEPT {return __imp_;} }; +#endif // !_LIBCPP_ABI_VCRUNTIME _LIBCPP_END_NAMESPACE_STD @@ -76,6 +78,7 @@ class _LIBCPP_EXCEPTION_ABI logic_error : public exception { +#ifndef _LIBCPP_ABI_VCRUNTIME private: _VSTD::__libcpp_refstring __imp_; public: @@ -88,11 +91,17 @@ virtual ~logic_error() _NOEXCEPT; virtual const char* what() const _NOEXCEPT; +#else +public: + explicit logic_error(const _VSTD::string&); // Symbol uses versioned std::string + _LIBCPP_INLINE_VISIBILITY explicit logic_error(const char* __s) : exception(__s) {} +#endif }; class _LIBCPP_EXCEPTION_ABI runtime_error : public exception { +#ifndef _LIBCPP_ABI_VCRUNTIME private: _VSTD::__libcpp_refstring __imp_; public: @@ -105,6 +114,11 @@ virtual ~runtime_error() _NOEXCEPT; virtual const char* what() const _NOEXCEPT; +#else +public: + explicit runtime_error(const _VSTD::string&); // Symbol uses versioned std::string + _LIBCPP_INLINE_VISIBILITY explicit runtime_error(const char* __s) : exception(__s) {} +#endif // _LIBCPP_ABI_VCRUNTIME }; class _LIBCPP_EXCEPTION_ABI domain_error @@ -114,7 +128,9 @@ _LIBCPP_INLINE_VISIBILITY explicit domain_error(const string& __s) : logic_error(__s) {} _LIBCPP_INLINE_VISIBILITY explicit domain_error(const char* __s) : logic_error(__s) {} +#ifndef _LIBCPP_ABI_VCRUNTIME virtual ~domain_error() _NOEXCEPT; +#endif }; class _LIBCPP_EXCEPTION_ABI invalid_argument @@ -124,7 +140,9 @@ _LIBCPP_INLINE_VISIBILITY explicit invalid_argument(const string& __s) : logic_error(__s) {} _LIBCPP_INLINE_VISIBILITY explicit invalid_argument(const char* __s) : logic_error(__s) {} +#ifndef _LIBCPP_ABI_VCRUNTIME virtual ~invalid_argument() _NOEXCEPT; +#endif }; class _LIBCPP_EXCEPTION_ABI length_error @@ -133,8 +151,9 @@ public: _LIBCPP_INLINE_VISIBILITY explicit length_error(const string& __s) : logic_error(__s) {} _LIBCPP_INLINE_VISIBILITY explicit length_error(const char* __s) : logic_error(__s) {} - +#ifndef _LIBCPP_ABI_VCRUNTIME virtual ~length_error() _NOEXCEPT; +#endif }; class _LIBCPP_EXCEPTION_ABI out_of_range @@ -144,7 +163,9 @@ _LIBCPP_INLINE_VISIBILITY explicit out_of_range(const string& __s) : logic_error(__s) {} _LIBCPP_INLINE_VISIBILITY explicit out_of_range(const char* __s) : logic_error(__s) {} +#ifndef _LIBCPP_ABI_VCRUNTIME virtual ~out_of_range() _NOEXCEPT; +#endif }; class _LIBCPP_EXCEPTION_ABI range_error @@ -154,7 +175,9 @@ _LIBCPP_INLINE_VISIBILITY explicit range_error(const string& __s) : runtime_error(__s) {} _LIBCPP_INLINE_VISIBILITY explicit range_error(const char* __s) : runtime_error(__s) {} +#ifndef _LIBCPP_ABI_VCRUNTIME virtual ~range_error() _NOEXCEPT; +#endif }; class _LIBCPP_EXCEPTION_ABI overflow_error @@ -164,7 +187,9 @@ _LIBCPP_INLINE_VISIBILITY explicit overflow_error(const string& __s) : runtime_error(__s) {} _LIBCPP_INLINE_VISIBILITY explicit overflow_error(const char* __s) : runtime_error(__s) {} +#ifndef _LIBCPP_ABI_VCRUNTIME virtual ~overflow_error() _NOEXCEPT; +#endif }; class _LIBCPP_EXCEPTION_ABI underflow_error @@ -174,7 +199,9 @@ _LIBCPP_INLINE_VISIBILITY explicit underflow_error(const string& __s) : runtime_error(__s) {} _LIBCPP_INLINE_VISIBILITY explicit underflow_error(const char* __s) : runtime_error(__s) {} +#ifndef _LIBCPP_ABI_VCRUNTIME virtual ~underflow_error() _NOEXCEPT; +#endif }; } // std Index: src/stdexcept.cpp =================================================================== --- src/stdexcept.cpp +++ src/stdexcept.cpp @@ -10,87 +10,10 @@ #include "new" #include "string" #include "system_error" -#include "include/refstring.h" -/* For _LIBCPPABI_VERSION */ -#if !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) && \ - (defined(LIBCXX_BUILDING_LIBCXXABI) || defined(__APPLE__) || defined(LIBCXXRT)) -#include -#endif - -static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char *), ""); - - -namespace std // purposefully not using versioning namespace -{ - -logic_error::logic_error(const string& msg) : __imp_(msg.c_str()) -{ -} - -logic_error::logic_error(const char* msg) : __imp_(msg) -{ -} - -logic_error::logic_error(const logic_error& le) _NOEXCEPT : __imp_(le.__imp_) -{ -} - -logic_error& -logic_error::operator=(const logic_error& le) _NOEXCEPT -{ - __imp_ = le.__imp_; - return *this; -} - -runtime_error::runtime_error(const string& msg) : __imp_(msg.c_str()) -{ -} - -runtime_error::runtime_error(const char* msg) : __imp_(msg) -{ -} - -runtime_error::runtime_error(const runtime_error& le) _NOEXCEPT - : __imp_(le.__imp_) -{ -} - -runtime_error& -runtime_error::operator=(const runtime_error& le) _NOEXCEPT -{ - __imp_ = le.__imp_; - return *this; -} - -#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX) - -const char* -logic_error::what() const _NOEXCEPT -{ - return __imp_.c_str(); -} - -const char* -runtime_error::what() const _NOEXCEPT -{ - return __imp_.c_str(); -} - -#if !defined(_LIBCPP_ABI_VCRUNTIME) - -logic_error::~logic_error() _NOEXCEPT {} -domain_error::~domain_error() _NOEXCEPT {} -invalid_argument::~invalid_argument() _NOEXCEPT {} -length_error::~length_error() _NOEXCEPT {} -out_of_range::~out_of_range() _NOEXCEPT {} - -runtime_error::~runtime_error() _NOEXCEPT {} -range_error::~range_error() _NOEXCEPT {} -overflow_error::~overflow_error() _NOEXCEPT {} -underflow_error::~underflow_error() _NOEXCEPT {} +#ifdef _LIBCPP_ABI_VCRUNTIME +#include "support/runtime/stdexcept_vcruntime.ipp" +#else +#include "support/runtime/stdexcept_default.ipp" #endif -#endif - -} // std Index: src/support/runtime/stdexcept_default.ipp =================================================================== --- src/support/runtime/stdexcept_default.ipp +++ src/support/runtime/stdexcept_default.ipp @@ -0,0 +1,65 @@ +//===--------------------- stdexcept_default.ipp --------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "../../include/refstring.h" + +/* For _LIBCPPABI_VERSION */ +#if !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) && \ + (defined(LIBCXX_BUILDING_LIBCXXABI) || defined(__APPLE__) || \ + defined(LIBCXXRT)) +#include +#endif + +static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char*), ""); + +namespace std // purposefully not using versioning namespace +{ + +logic_error::logic_error(const string& msg) : __imp_(msg.c_str()) {} + +logic_error::logic_error(const char* msg) : __imp_(msg) {} + +logic_error::logic_error(const logic_error& le) _NOEXCEPT : __imp_(le.__imp_) {} + +logic_error& logic_error::operator=(const logic_error& le) _NOEXCEPT { + __imp_ = le.__imp_; + return *this; +} + +runtime_error::runtime_error(const string& msg) : __imp_(msg.c_str()) {} + +runtime_error::runtime_error(const char* msg) : __imp_(msg) {} + +runtime_error::runtime_error(const runtime_error& re) _NOEXCEPT + : __imp_(re.__imp_) {} + +runtime_error& runtime_error::operator=(const runtime_error& re) _NOEXCEPT { + __imp_ = re.__imp_; + return *this; +} + +#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX) + +const char* logic_error::what() const _NOEXCEPT { return __imp_.c_str(); } + +const char* runtime_error::what() const _NOEXCEPT { return __imp_.c_str(); } + +logic_error::~logic_error() _NOEXCEPT {} +domain_error::~domain_error() _NOEXCEPT {} +invalid_argument::~invalid_argument() _NOEXCEPT {} +length_error::~length_error() _NOEXCEPT {} +out_of_range::~out_of_range() _NOEXCEPT {} + +runtime_error::~runtime_error() _NOEXCEPT {} +range_error::~range_error() _NOEXCEPT {} +overflow_error::~overflow_error() _NOEXCEPT {} +underflow_error::~underflow_error() _NOEXCEPT {} + +#endif + +} // namespace std Index: src/support/runtime/stdexcept_vcruntime.ipp =================================================================== --- src/support/runtime/stdexcept_vcruntime.ipp +++ src/support/runtime/stdexcept_vcruntime.ipp @@ -0,0 +1,16 @@ +//===------------------- stdexcept_vcruntime.ipp --------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_ABI_VCRUNTIME +#error This file may only be used when defering to vcruntime +#endif + +namespace std { +logic_error::logic_error(std::string const& s) : exception(s.c_str()) {} +runtime_error::runtime_error(std::string const& s) : exception(s.c_str()) {} +} // namespace std