diff --git a/libcxx/include/__memory/shared_ptr.h b/libcxx/include/__memory/shared_ptr.h --- a/libcxx/include/__memory/shared_ptr.h +++ b/libcxx/include/__memory/shared_ptr.h @@ -47,6 +47,17 @@ # pragma GCC system_header #endif +namespace std { +class _LIBCPP_EXCEPTION_ABI bad_weak_ptr : public std::exception { +public: + bad_weak_ptr() _NOEXCEPT = default; + bad_weak_ptr(const bad_weak_ptr&) _NOEXCEPT = default; + ~bad_weak_ptr() _NOEXCEPT override; + const char* what() const _NOEXCEPT override; +}; + +} // namespace std + _LIBCPP_BEGIN_NAMESPACE_STD // NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively) @@ -106,16 +117,6 @@ #endif } -class _LIBCPP_EXCEPTION_ABI bad_weak_ptr - : public std::exception -{ -public: - bad_weak_ptr() _NOEXCEPT = default; - bad_weak_ptr(const bad_weak_ptr&) _NOEXCEPT = default; - ~bad_weak_ptr() _NOEXCEPT override; - const char* what() const _NOEXCEPT override; -}; - _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY void __throw_bad_weak_ptr() { diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt --- a/libcxx/src/CMakeLists.txt +++ b/libcxx/src/CMakeLists.txt @@ -60,7 +60,6 @@ typeinfo.cpp utility.cpp valarray.cpp - variant.cpp vector.cpp verbose_abort.cpp ) diff --git a/libcxx/src/any.cpp b/libcxx/src/any.cpp --- a/libcxx/src/any.cpp +++ b/libcxx/src/any.cpp @@ -8,13 +8,6 @@ #include -namespace std { -const char* bad_any_cast::what() const noexcept { - return "bad any cast"; -} -} - - #include // Preserve std::experimental::any_bad_cast for ABI compatibility diff --git a/libcxx/src/memory.cpp b/libcxx/src/memory.cpp --- a/libcxx/src/memory.cpp +++ b/libcxx/src/memory.cpp @@ -27,14 +27,6 @@ const allocator_arg_t allocator_arg = allocator_arg_t(); -bad_weak_ptr::~bad_weak_ptr() noexcept {} - -const char* -bad_weak_ptr::what() const noexcept -{ - return "bad_weak_ptr"; -} - __shared_count::~__shared_count() { } diff --git a/libcxx/src/optional.cpp b/libcxx/src/optional.cpp --- a/libcxx/src/optional.cpp +++ b/libcxx/src/optional.cpp @@ -9,18 +9,6 @@ #include <__availability> #include -namespace std -{ - -bad_optional_access::~bad_optional_access() noexcept = default; - -const char* bad_optional_access::what() const noexcept { - return "bad_optional_access"; -} - -} // std - - #include // Preserve std::experimental::bad_optional_access for ABI compatibility diff --git a/libcxx/src/variant.cpp b/libcxx/src/variant.cpp deleted file mode 100644 --- a/libcxx/src/variant.cpp +++ /dev/null @@ -1,17 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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 - -namespace std { - -const char* bad_variant_access::what() const noexcept { - return "bad_variant_access"; -} - -} // namespace std diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt --- a/libcxxabi/src/CMakeLists.txt +++ b/libcxxabi/src/CMakeLists.txt @@ -10,6 +10,7 @@ cxa_vector.cpp cxa_virtual.cpp # C++ STL files + exceptions.cpp stdlib_exception.cpp stdlib_stdexcept.cpp stdlib_typeinfo.cpp diff --git a/libcxxabi/src/exceptions.cpp b/libcxxabi/src/exceptions.cpp new file mode 100644 --- /dev/null +++ b/libcxxabi/src/exceptions.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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 +#include +#include + +namespace std { +bad_weak_ptr::~bad_weak_ptr() noexcept {} +const char* bad_weak_ptr::what() const noexcept { return "bad_weak_ptr"; } + +const char* bad_any_cast::what() const noexcept { return "bad any cast"; } + +bad_optional_access::~bad_optional_access() noexcept = default; +const char* bad_optional_access::what() const noexcept { return "bad_optional_access"; } + +const char* bad_variant_access::what() const noexcept { return "bad_variant_access"; } +} // namespace std