Skip to content

Commit 090996f

Browse files
committed
[libc++] Work around dynamic linking of stringstream::str() on Windows
Also `istringstream::str()` and `ostringstrem::str()`. llvm#40363 causes `str()` to be dllimport'ed despite _LIBCPP_HIDE_FROM_ABI. This is a temporary solution until llvm#40363 is fixed. Reviewed By: #libc, thakis, philnik Differential Revision: https://reviews.llvm.org/D157602
1 parent 1e22873 commit 090996f

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

libcxx/include/sstream

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ public:
419419
}
420420

421421
_LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept;
422-
#endif
422+
#endif // _LIBCPP_STD_VER >= 20
423423

424424
void str(const string_type& __s) {
425425
__str_ = __s;
@@ -904,20 +904,22 @@ public:
904904
return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
905905
}
906906

907-
#if _LIBCPP_STD_VER >= 20
908-
_LIBCPP_HIDE_FROM_ABI string_type str() const & { return __sb_.str(); }
907+
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
908+
_LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); }
909+
#else
910+
_LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() const & { return __sb_.str(); }
911+
912+
_LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() && { return std::move(__sb_).str(); }
913+
#endif
909914

915+
#if _LIBCPP_STD_VER >= 20
910916
template <class _SAlloc>
911917
requires __is_allocator<_SAlloc>::value
912918
_LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const {
913919
return __sb_.str(__sa);
914920
}
915921

916-
_LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); }
917-
918922
_LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); }
919-
#else // _LIBCPP_STD_VER >= 20
920-
_LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); }
921923
#endif // _LIBCPP_STD_VER >= 20
922924

923925
_LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); }
@@ -1027,20 +1029,22 @@ public:
10271029
return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
10281030
}
10291031

1030-
#if _LIBCPP_STD_VER >= 20
1031-
_LIBCPP_HIDE_FROM_ABI string_type str() const & { return __sb_.str(); }
1032+
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
1033+
_LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); }
1034+
#else
1035+
_LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() const & { return __sb_.str(); }
10321036

1037+
_LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() && { return std::move(__sb_).str(); }
1038+
#endif
1039+
1040+
#if _LIBCPP_STD_VER >= 20
10331041
template <class _SAlloc>
10341042
requires __is_allocator<_SAlloc>::value
10351043
_LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const {
10361044
return __sb_.str(__sa);
10371045
}
10381046

1039-
_LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); }
1040-
10411047
_LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); }
1042-
#else // _LIBCPP_STD_VER >= 20
1043-
_LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); }
10441048
#endif // _LIBCPP_STD_VER >= 20
10451049

10461050
_LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); }
@@ -1149,20 +1153,22 @@ public:
11491153
return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
11501154
}
11511155

1152-
#if _LIBCPP_STD_VER >= 20
1153-
_LIBCPP_HIDE_FROM_ABI string_type str() const & { return __sb_.str(); }
1156+
#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
1157+
_LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); }
1158+
#else
1159+
_LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() const & { return __sb_.str(); }
1160+
1161+
_LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() && { return std::move(__sb_).str(); }
1162+
#endif
11541163

1164+
#if _LIBCPP_STD_VER >= 20
11551165
template <class _SAlloc>
11561166
requires __is_allocator<_SAlloc>::value
11571167
_LIBCPP_HIDE_FROM_ABI basic_string<char_type, traits_type, _SAlloc> str(const _SAlloc& __sa) const {
11581168
return __sb_.str(__sa);
11591169
}
11601170

1161-
_LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); }
1162-
11631171
_LIBCPP_HIDE_FROM_ABI basic_string_view<char_type, traits_type> view() const noexcept { return __sb_.view(); }
1164-
#else // _LIBCPP_STD_VER >= 20
1165-
_LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); }
11661172
#endif // _LIBCPP_STD_VER >= 20
11671173

11681174
_LIBCPP_HIDE_FROM_ABI void str(const string_type& __s) { __sb_.str(__s); }

0 commit comments

Comments
 (0)