[libcxx-commits] [libcxx] 014a673 - [libc++] Remove std::basic_string's base class in ABIv2
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jan 24 15:23:40 PST 2022
Author: Nikolas Klauser
Date: 2022-01-25T00:21:53+01:00
New Revision: 014a673441c6050683e059a547ffcbb03004730d
URL: https://github.com/llvm/llvm-project/commit/014a673441c6050683e059a547ffcbb03004730d
DIFF: https://github.com/llvm/llvm-project/commit/014a673441c6050683e059a547ffcbb03004730d.diff
LOG: [libc++] Remove std::basic_string's base class in ABIv2
Remove `std::basic_string`'s base class in ABI version 2
Reviewed By: Quuxplusone, ldionne, #libc
Spies: libcxx-commits
Differential Revision: https://reviews.llvm.org/D116334
Added:
Modified:
libcxx/include/__config
libcxx/include/string
libcxx/src/string.cpp
Removed:
################################################################################
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 4c6edd45ff0a5..b99cdc38dc9f8 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -114,6 +114,8 @@
// compatible. This switch removes these workarounds for platforms that don't care
// about ABI compatibility.
# define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT
+// Remove basic_string common base
+# define _LIBCPP_ABI_NO_BASIC_STRING_BASE_CLASS
#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 f53e1bfef75e8..3616de8a214d8 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -618,6 +618,7 @@ 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;
@@ -627,6 +628,7 @@ 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;
};
+#endif
template <class _Iter>
struct __string_is_trivial_iterator : public false_type {};
@@ -680,7 +682,9 @@ 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;
@@ -1729,20 +1733,12 @@ private:
_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
void __throw_length_error() const {
-#ifndef _LIBCPP_NO_EXCEPTIONS
- __basic_string_common<true>::__throw_length_error();
-#else
- _VSTD::abort();
-#endif
+ _VSTD::__throw_length_error("basic_string");
}
_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
void __throw_out_of_range() const {
-#ifndef _LIBCPP_NO_EXCEPTIONS
- __basic_string_common<true>::__throw_out_of_range();
-#else
- _VSTD::abort();
-#endif
+ _VSTD::__throw_out_of_range("basic_string");
}
friend basic_string operator+<>(const basic_string&, const basic_string&);
diff --git a/libcxx/src/string.cpp b/libcxx/src/string.cpp
index 608dcb2c5863f..3c63f408240d3 100644
--- a/libcxx/src/string.cpp
+++ b/libcxx/src/string.cpp
@@ -21,6 +21,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#ifndef _LIBCPP_ABI_NO_BASIC_STRING_BASE_CLASS
void __basic_string_common<true>::__throw_length_error() const {
_VSTD::__throw_length_error("basic_string");
}
@@ -28,6 +29,7 @@ void __basic_string_common<true>::__throw_length_error() const {
void __basic_string_common<true>::__throw_out_of_range() const {
_VSTD::__throw_out_of_range("basic_string");
}
+#endif
#define _LIBCPP_EXTERN_TEMPLATE_DEFINE(...) template __VA_ARGS__;
#ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
More information about the libcxx-commits
mailing list