Author: Nikolas Klauser Date: 2022-02-03T17:47:51-05:00 New Revision: d5e113c969bf4b6ac7f9f8872ee1ceaed22b1750
URL: https://github.com/llvm/llvm-project/commit/d5e113c969bf4b6ac7f9f8872ee1ceaed22b1750 DIFF: https://github.com/llvm/llvm-project/commit/d5e113c969bf4b6ac7f9f8872ee1ceaed22b1750.diff LOG: [libc++] Remove the std::string base class Removing the base class of std::basic_string is not an ABI break, so we can remove any references to it from the header. Reviewed By: ldionne, Mordante, #libc Spies: libcxx-commits Differential Revision: https://reviews.llvm.org/D118733 (cherry picked from commit 5173f43cc892539271c34c5612fe783b51025da9) Added: Modified: libcxx/include/__config libcxx/include/string libcxx/src/string.cpp Removed: ################################################################################ diff --git a/libcxx/include/__config b/libcxx/include/__config index 3c3d4b57c76e4..d2d70c4ed7694 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -115,7 +115,7 @@ // about ABI compatibility. # define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT // Remove basic_string common base -# define _LIBCPP_ABI_NO_BASIC_STRING_BASE_CLASS +# define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON #elif _LIBCPP_ABI_VERSION == 1 # if !defined(_LIBCPP_OBJECT_FORMAT_COFF) // Enable compiling copies of now inline methods into the dylib to support diff --git a/libcxx/include/string b/libcxx/include/string index 3616de8a214d8..01cff902e07db 100644 --- a/libcxx/include/string +++ b/libcxx/include/string @@ -618,18 +618,6 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y); _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&)) -#ifndef _LIBCPP_ABI_NO_BASIC_STRING_BASE_CLASS -template <bool> -struct __basic_string_common; - -template <> -struct __basic_string_common<true> { - // Both are defined in string.cpp - _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error() const; - _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const; -}; -#endif - template <class _Iter> struct __string_is_trivial_iterator : public false_type {}; @@ -682,9 +670,6 @@ class _LIBCPP_PREFERRED_NAME(u32string) #endif basic_string -#ifndef _LIBCPP_ABI_NO_BASIC_STRING_BASE_CLASS - : private __basic_string_common<true> // This base class is historical, but it needs to remain for ABI compatibility -#endif { public: typedef basic_string __self; diff --git a/libcxx/src/string.cpp b/libcxx/src/string.cpp index 3c63f408240d3..3cde2e9005ba2 100644 --- a/libcxx/src/string.cpp +++ b/libcxx/src/string.cpp @@ -21,15 +21,26 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#ifndef _LIBCPP_ABI_NO_BASIC_STRING_BASE_CLASS +#ifndef _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON + +template <bool> +struct __basic_string_common; + +// The struct isn't declared anymore in the headers. It's only here for ABI compatibility. +template <> +struct __basic_string_common<true> { + _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error() const; + _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const; +}; + void __basic_string_common<true>::__throw_length_error() const { - _VSTD::__throw_length_error("basic_string"); + std::__throw_length_error("basic_string"); } - void __basic_string_common<true>::__throw_out_of_range() const { - _VSTD::__throw_out_of_range("basic_string"); + std::__throw_out_of_range("basic_string"); } -#endif + +#endif // _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON #define _LIBCPP_EXTERN_TEMPLATE_DEFINE(...) template __VA_ARGS__; #ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits