Skip to content

Commit 5891e73

Browse files
committed
[libc++] Move std::string extern template declarations to end of class.
They need to appear before any member functions are ODR used, because they change the visibility of many of these functions and otherwise they could end up with hidden visibility in the DSO.
1 parent 30cbdcb commit 5891e73

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

libcxx/include/string

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,6 +1672,17 @@ private:
16721672
friend basic_string operator+<>(const basic_string&, value_type);
16731673
};
16741674

1675+
// These declarations must appear before any functions are implicitly used
1676+
// so that they have the correct visibility specifier.
1677+
#ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
1678+
_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char)
1679+
_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t)
1680+
#else
1681+
_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char)
1682+
_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t)
1683+
#endif
1684+
1685+
16751686
#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
16761687
template<class _InputIterator,
16771688
class _CharT = typename iterator_traits<_InputIterator>::value_type,
@@ -4413,14 +4424,6 @@ basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator*
44134424

44144425
#endif // _LIBCPP_DEBUG_LEVEL >= 2
44154426

4416-
#ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
4417-
_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char)
4418-
_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t)
4419-
#else
4420-
_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char)
4421-
_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t)
4422-
#endif
4423-
44244427
#if _LIBCPP_STD_VER > 11
44254428
// Literal suffixes for basic_string [basic.string.literals]
44264429
inline namespace literals

0 commit comments

Comments
 (0)