[libcxx-commits] [libcxx] 5891e73 - [libc++] Move std::string extern template declarations to end of class.

Eric Fiselier via libcxx-commits libcxx-commits at lists.llvm.org
Wed Mar 4 10:57:51 PST 2020


Author: Eric Fiselier
Date: 2020-03-04T13:57:29-05:00
New Revision: 5891e7302f897771c9686a80a4afbf6a36d9b2ac

URL: https://github.com/llvm/llvm-project/commit/5891e7302f897771c9686a80a4afbf6a36d9b2ac
DIFF: https://github.com/llvm/llvm-project/commit/5891e7302f897771c9686a80a4afbf6a36d9b2ac.diff

LOG: [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.

Added: 
    

Modified: 
    libcxx/include/string

Removed: 
    


################################################################################
diff  --git a/libcxx/include/string b/libcxx/include/string
index ffa8c66f7e35..e8245bfc1526 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -1672,6 +1672,17 @@ private:
     friend basic_string operator+<>(const basic_string&, value_type);
 };
 
+// These declarations must appear before any functions are implicitly used
+// so that they have the correct visibility specifier.
+#ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
+_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char)
+_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t)
+#else
+_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char)
+_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t)
+#endif
+
+
 #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
 template<class _InputIterator,
          class _CharT = typename iterator_traits<_InputIterator>::value_type,
@@ -4413,14 +4424,6 @@ basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator*
 
 #endif  // _LIBCPP_DEBUG_LEVEL >= 2
 
-#ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
-_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char)
-_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t)
-#else
-_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char)
-_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t)
-#endif
-
 #if _LIBCPP_STD_VER > 11
 // Literal suffixes for basic_string [basic.string.literals]
 inline namespace literals


        


More information about the libcxx-commits mailing list