diff options
author | Piotr Fusik <fox@scene.pl> | 2023-07-14 18:30:41 +0200 |
---|---|---|
committer | Piotr Fusik <fox@scene.pl> | 2023-07-19 17:13:34 +0200 |
commit | 8ecb9591646d4b0326ea7547b99d300336c6c423 (patch) | |
tree | 5d1aa04e289a038925182c8118eb58edc92e962a | |
parent | 8981520b19f2d2fe3d2bc80cf26318ee6b5b7473 (diff) | |
download | llvm-8ecb9591646d4b0326ea7547b99d300336c6c423.zip llvm-8ecb9591646d4b0326ea7547b99d300336c6c423.tar.gz llvm-8ecb9591646d4b0326ea7547b99d300336c6c423.tar.bz2 |
[libc++] Work around dynamic linking of stringbuf::str() on Windows
https://github.com/llvm/llvm-project/issues/40363 caused the C++20
`str() const &` and `str() &&` to be dllimport'ed despite _LIBCPP_HIDE_FROM_ABI.
This is a temporary solution until #40363 is fixed.
Reviewed By: #libc, hans, ldionne, Mordante
Differential Revision: https://reviews.llvm.org/D155185
-rw-r--r-- | libcxx/include/sstream | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/libcxx/include/sstream b/libcxx/include/sstream index d425687..d7ad021 100644 --- a/libcxx/include/sstream +++ b/libcxx/include/sstream @@ -283,6 +283,14 @@ _LIBCPP_PUSH_MACROS #include <__undef_macros> +// TODO(LLVM-19): Remove this once we drop support for Clang 16, +// which had this bug: https://github.com/llvm/llvm-project/issues/40363 +#ifdef _WIN32 +#define _LIBCPP_HIDE_FROM_ABI_SSTREAM _LIBCPP_ALWAYS_INLINE +#else +#define _LIBCPP_HIDE_FROM_ABI_SSTREAM _LIBCPP_HIDE_FROM_ABI +#endif + _LIBCPP_BEGIN_NAMESPACE_STD // Class template basic_stringbuf [stringbuf] @@ -388,15 +396,9 @@ public: #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) string_type str() const; #else - _LIBCPP_HIDE_FROM_ABI string_type str() const & { return str(__str_.get_allocator()); } + _LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() const & { return str(__str_.get_allocator()); } - template <class _SAlloc> - requires __is_allocator<_SAlloc>::value - _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const { - return basic_string<_CharT, _Traits, _SAlloc>(view(), __sa); - } - - _LIBCPP_HIDE_FROM_ABI string_type str() && { + _LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() && { const basic_string_view<_CharT, _Traits> __view = view(); string_type __result(std::move(__str_), __view.data() - __str_.data(), __view.size()); __str_.clear(); @@ -406,6 +408,12 @@ public: #endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY) #if _LIBCPP_STD_VER >= 20 + template <class _SAlloc> + requires __is_allocator<_SAlloc>::value + _LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const { + return basic_string<_CharT, _Traits, _SAlloc>(view(), __sa); + } + _LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept; #endif |