diff --git a/libcxx/include/__config b/libcxx/include/__config --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -544,16 +544,24 @@ # endif # define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS +# define _LIBCPP_FRIEND_TYPE_VIS _LIBCPP_DLL_VIS # define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS # define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS # define _LIBCPP_HIDDEN # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS # define _LIBCPP_TEMPLATE_VIS +# define _LIBCPP_FRIEND_TEMPLATE_VIS # define _LIBCPP_TEMPLATE_DATA_VIS # define _LIBCPP_ENUM_VIS # else +# if !defined(_LIBCPP_DISABLE_LTO_VISIBILITY_ANNOTATIONS) && defined(__clang__) +# define _LIBCPP_LTO_VISIBILITY [[clang::lto_visibility_public]] +# else +# define _LIBCPP_LTO_VISIBILITY +# endif + # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) # define _LIBCPP_VISIBILITY(vis) __attribute__((__visibility__(vis))) # else @@ -562,7 +570,8 @@ # define _LIBCPP_HIDDEN _LIBCPP_VISIBILITY("hidden") # define _LIBCPP_FUNC_VIS _LIBCPP_VISIBILITY("default") -# define _LIBCPP_TYPE_VIS _LIBCPP_VISIBILITY("default") +# define _LIBCPP_TYPE_VIS _LIBCPP_VISIBILITY("default") _LIBCPP_LTO_VISIBILITY +# define _LIBCPP_FRIEND_TYPE_VIS _LIBCPP_VISIBILITY("default") # define _LIBCPP_TEMPLATE_DATA_VIS _LIBCPP_VISIBILITY("default") # define _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_VISIBILITY("default") # define _LIBCPP_EXCEPTION_ABI _LIBCPP_VISIBILITY("default") @@ -587,8 +596,10 @@ # else # define _LIBCPP_TEMPLATE_VIS __attribute__((__visibility__("default"))) # endif +# define _LIBCPP_FRIEND_TEMPLATE_VIS _LIBCPP_TEMPLATE_VIS # else -# define _LIBCPP_TEMPLATE_VIS +# define _LIBCPP_TEMPLATE_VIS _LIBCPP_LTO_VISIBILITY +# define _LIBCPP_FRIEND_TEMPLATE_VIS # endif # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) diff --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table --- a/libcxx/include/__hash_table +++ b/libcxx/include/__hash_table @@ -385,10 +385,10 @@ #endif } template friend class __hash_table; - template friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator; - template friend class _LIBCPP_TEMPLATE_VIS __hash_map_iterator; - template friend class _LIBCPP_TEMPLATE_VIS unordered_map; - template friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS __hash_const_iterator; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS __hash_map_iterator; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS unordered_map; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS unordered_multimap; }; template @@ -499,9 +499,9 @@ #endif } template friend class __hash_table; - template friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator; - template friend class _LIBCPP_TEMPLATE_VIS unordered_map; - template friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS __hash_map_const_iterator; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS unordered_map; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS unordered_multimap; }; template @@ -613,8 +613,8 @@ __node_ = __node_->__next_; } template friend class __hash_table; - template friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator; - template friend class _LIBCPP_TEMPLATE_VIS __hash_map_iterator; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS __hash_const_local_iterator; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS __hash_map_iterator; }; template @@ -746,7 +746,7 @@ __node_ = __node_->__next_; } template friend class __hash_table; - template friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS __hash_map_const_iterator; }; template @@ -1356,8 +1356,8 @@ void __deallocate_node(__next_pointer __np) _NOEXCEPT; __next_pointer __detach() _NOEXCEPT; - template friend class _LIBCPP_TEMPLATE_VIS unordered_map; - template friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS unordered_map; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS unordered_multimap; }; template diff --git a/libcxx/include/__iterator/wrap_iter.h b/libcxx/include/__iterator/wrap_iter.h --- a/libcxx/include/__iterator/wrap_iter.h +++ b/libcxx/include/__iterator/wrap_iter.h @@ -148,8 +148,10 @@ template friend class __wrap_iter; template friend class basic_string; - template friend class _LIBCPP_TEMPLATE_VIS vector; - template friend class _LIBCPP_TEMPLATE_VIS span; + template + friend class _LIBCPP_FRIEND_TEMPLATE_VIS vector; + template + friend class _LIBCPP_FRIEND_TEMPLATE_VIS span; }; template diff --git a/libcxx/include/__memory/shared_ptr.h b/libcxx/include/__memory/shared_ptr.h --- a/libcxx/include/__memory/shared_ptr.h +++ b/libcxx/include/__memory/shared_ptr.h @@ -987,8 +987,10 @@ : default_delete<_Yp[]> { }; - template friend class _LIBCPP_TEMPLATE_VIS shared_ptr; - template friend class _LIBCPP_TEMPLATE_VIS weak_ptr; + template + friend class _LIBCPP_FRIEND_TEMPLATE_VIS shared_ptr; + template + friend class _LIBCPP_FRIEND_TEMPLATE_VIS weak_ptr; }; #if _LIBCPP_STD_VER >= 17 @@ -1644,8 +1646,10 @@ bool owner_before(const weak_ptr<_Up>& __r) const _NOEXCEPT {return __cntrl_ < __r.__cntrl_;} - template friend class _LIBCPP_TEMPLATE_VIS weak_ptr; - template friend class _LIBCPP_TEMPLATE_VIS shared_ptr; + template + friend class _LIBCPP_FRIEND_TEMPLATE_VIS weak_ptr; + template + friend class _LIBCPP_FRIEND_TEMPLATE_VIS shared_ptr; }; #if _LIBCPP_STD_VER >= 17 diff --git a/libcxx/include/__threading_support b/libcxx/include/__threading_support --- a/libcxx/include/__threading_support +++ b/libcxx/include/__threading_support @@ -644,8 +644,8 @@ __thread_id(__libcpp_thread_id __id) : __id_(__id) {} friend __thread_id this_thread::get_id() _NOEXCEPT; - friend class _LIBCPP_TYPE_VIS thread; - friend struct _LIBCPP_TEMPLATE_VIS hash<__thread_id>; + friend class _LIBCPP_FRIEND_TYPE_VIS thread; + friend struct _LIBCPP_FRIEND_TEMPLATE_VIS hash<__thread_id>; }; inline _LIBCPP_HIDE_FROM_ABI diff --git a/libcxx/include/__tree b/libcxx/include/__tree --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -895,12 +895,12 @@ _LIBCPP_INLINE_VISIBILITY __node_pointer __get_np() const { return static_cast<__node_pointer>(__ptr_); } template friend class __tree; - template friend class _LIBCPP_TEMPLATE_VIS __tree_const_iterator; - template friend class _LIBCPP_TEMPLATE_VIS __map_iterator; - template friend class _LIBCPP_TEMPLATE_VIS map; - template friend class _LIBCPP_TEMPLATE_VIS multimap; - template friend class _LIBCPP_TEMPLATE_VIS set; - template friend class _LIBCPP_TEMPLATE_VIS multiset; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS __tree_const_iterator; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS __map_iterator; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS map; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS multimap; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS set; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS multiset; }; template @@ -981,11 +981,11 @@ __node_pointer __get_np() const { return static_cast<__node_pointer>(__ptr_); } template friend class __tree; - template friend class _LIBCPP_TEMPLATE_VIS map; - template friend class _LIBCPP_TEMPLATE_VIS multimap; - template friend class _LIBCPP_TEMPLATE_VIS set; - template friend class _LIBCPP_TEMPLATE_VIS multiset; - template friend class _LIBCPP_TEMPLATE_VIS __map_const_iterator; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS map; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS multimap; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS set; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS multiset; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS __map_const_iterator; }; @@ -1542,8 +1542,8 @@ }; - template friend class _LIBCPP_TEMPLATE_VIS map; - template friend class _LIBCPP_TEMPLATE_VIS multimap; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS map; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS multimap; }; template diff --git a/libcxx/include/deque b/libcxx/include/deque --- a/libcxx/include/deque +++ b/libcxx/include/deque @@ -390,9 +390,9 @@ _LIBCPP_HIDE_FROM_ABI explicit __deque_iterator(__map_iterator __m, pointer __p) _NOEXCEPT : __m_iter_(__m), __ptr_(__p) {} - template friend class _LIBCPP_TEMPLATE_VIS deque; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS deque; template - friend class _LIBCPP_TEMPLATE_VIS __deque_iterator; + friend class _LIBCPP_FRIEND_TEMPLATE_VIS __deque_iterator; template friend struct __segmented_iterator_traits; diff --git a/libcxx/include/ext/hash_map b/libcxx/include/ext/hash_map --- a/libcxx/include/ext/hash_map +++ b/libcxx/include/ext/hash_map @@ -403,11 +403,11 @@ bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y) {return __x.__i_ != __y.__i_;} - template friend class _LIBCPP_TEMPLATE_VIS hash_map; - template friend class _LIBCPP_TEMPLATE_VIS hash_multimap; - template friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator; - template friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator; - template friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS hash_map; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS hash_multimap; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS __hash_const_iterator; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS __hash_const_local_iterator; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS __hash_map_const_iterator; }; template @@ -456,10 +456,10 @@ bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) {return __x.__i_ != __y.__i_;} - template friend class _LIBCPP_TEMPLATE_VIS hash_map; - template friend class _LIBCPP_TEMPLATE_VIS hash_multimap; - template friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator; - template friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS hash_map; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS hash_multimap; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS __hash_const_iterator; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS __hash_const_local_iterator; }; template , class _Pred = std::equal_to<_Key>, diff --git a/libcxx/include/forward_list b/libcxx/include/forward_list --- a/libcxx/include/forward_list +++ b/libcxx/include/forward_list @@ -347,8 +347,8 @@ explicit __forward_list_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__traits::__as_iter_node(__p)) {} - template friend class _LIBCPP_TEMPLATE_VIS forward_list; - template friend class _LIBCPP_TEMPLATE_VIS __forward_list_const_iterator; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS forward_list; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS __forward_list_const_iterator; public: typedef forward_iterator_tag iterator_category; diff --git a/libcxx/include/map b/libcxx/include/map --- a/libcxx/include/map +++ b/libcxx/include/map @@ -908,9 +908,9 @@ bool operator!=(const __map_iterator& __x, const __map_iterator& __y) {return __x.__i_ != __y.__i_;} - template friend class _LIBCPP_TEMPLATE_VIS map; - template friend class _LIBCPP_TEMPLATE_VIS multimap; - template friend class _LIBCPP_TEMPLATE_VIS __map_const_iterator; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS map; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS multimap; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS __map_const_iterator; }; template @@ -970,9 +970,9 @@ bool operator!=(const __map_const_iterator& __x, const __map_const_iterator& __y) {return __x.__i_ != __y.__i_;} - template friend class _LIBCPP_TEMPLATE_VIS map; - template friend class _LIBCPP_TEMPLATE_VIS multimap; - template friend class _LIBCPP_TEMPLATE_VIS __tree_const_iterator; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS map; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS multimap; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS __tree_const_iterator; }; template , @@ -1037,9 +1037,9 @@ #endif template - friend class _LIBCPP_TEMPLATE_VIS map; + friend class _LIBCPP_FRIEND_TEMPLATE_VIS map; template - friend class _LIBCPP_TEMPLATE_VIS multimap; + friend class _LIBCPP_FRIEND_TEMPLATE_VIS multimap; _LIBCPP_INLINE_VISIBILITY map() @@ -1832,9 +1832,9 @@ #endif template - friend class _LIBCPP_TEMPLATE_VIS map; + friend class _LIBCPP_FRIEND_TEMPLATE_VIS map; template - friend class _LIBCPP_TEMPLATE_VIS multimap; + friend class _LIBCPP_FRIEND_TEMPLATE_VIS multimap; _LIBCPP_INLINE_VISIBILITY multimap() diff --git a/libcxx/include/set b/libcxx/include/set --- a/libcxx/include/set +++ b/libcxx/include/set @@ -553,9 +553,9 @@ #endif template - friend class _LIBCPP_TEMPLATE_VIS set; + friend class _LIBCPP_FRIEND_TEMPLATE_VIS set; template - friend class _LIBCPP_TEMPLATE_VIS multiset; + friend class _LIBCPP_FRIEND_TEMPLATE_VIS multiset; _LIBCPP_INLINE_VISIBILITY set() @@ -1089,9 +1089,9 @@ #endif template - friend class _LIBCPP_TEMPLATE_VIS set; + friend class _LIBCPP_FRIEND_TEMPLATE_VIS set; template - friend class _LIBCPP_TEMPLATE_VIS multiset; + friend class _LIBCPP_FRIEND_TEMPLATE_VIS multiset; // construct/copy/destroy: _LIBCPP_INLINE_VISIBILITY diff --git a/libcxx/include/unordered_map b/libcxx/include/unordered_map --- a/libcxx/include/unordered_map +++ b/libcxx/include/unordered_map @@ -957,11 +957,11 @@ bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y) {return __x.__i_ != __y.__i_;} - template friend class _LIBCPP_TEMPLATE_VIS unordered_map; - template friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; - template friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator; - template friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator; - template friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS unordered_map; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS unordered_multimap; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS __hash_const_iterator; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS __hash_const_local_iterator; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS __hash_map_const_iterator; }; template @@ -1011,10 +1011,10 @@ bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) {return __x.__i_ != __y.__i_;} - template friend class _LIBCPP_TEMPLATE_VIS unordered_map; - template friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; - template friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator; - template friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS unordered_map; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS unordered_multimap; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS __hash_const_iterator; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS __hash_const_local_iterator; }; template @@ -1081,9 +1081,9 @@ #endif template - friend class _LIBCPP_TEMPLATE_VIS unordered_map; + friend class _LIBCPP_FRIEND_TEMPLATE_VIS unordered_map; template - friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; + friend class _LIBCPP_FRIEND_TEMPLATE_VIS unordered_multimap; _LIBCPP_INLINE_VISIBILITY unordered_map() @@ -1972,9 +1972,9 @@ #endif template - friend class _LIBCPP_TEMPLATE_VIS unordered_map; + friend class _LIBCPP_FRIEND_TEMPLATE_VIS unordered_map; template - friend class _LIBCPP_TEMPLATE_VIS unordered_multimap; + friend class _LIBCPP_FRIEND_TEMPLATE_VIS unordered_multimap; _LIBCPP_INLINE_VISIBILITY unordered_multimap() diff --git a/libcxx/include/unordered_set b/libcxx/include/unordered_set --- a/libcxx/include/unordered_set +++ b/libcxx/include/unordered_set @@ -541,9 +541,9 @@ #endif template - friend class _LIBCPP_TEMPLATE_VIS unordered_set; + friend class _LIBCPP_FRIEND_TEMPLATE_VIS unordered_set; template - friend class _LIBCPP_TEMPLATE_VIS unordered_multiset; + friend class _LIBCPP_FRIEND_TEMPLATE_VIS unordered_multiset; _LIBCPP_INLINE_VISIBILITY unordered_set() @@ -1196,9 +1196,9 @@ #endif template - friend class _LIBCPP_TEMPLATE_VIS unordered_set; + friend class _LIBCPP_FRIEND_TEMPLATE_VIS unordered_set; template - friend class _LIBCPP_TEMPLATE_VIS unordered_multiset; + friend class _LIBCPP_FRIEND_TEMPLATE_VIS unordered_multiset; _LIBCPP_INLINE_VISIBILITY unordered_multiset() diff --git a/libcxx/include/valarray b/libcxx/include/valarray --- a/libcxx/include/valarray +++ b/libcxx/include/valarray @@ -717,7 +717,7 @@ size_t size() const {return __size_;} template friend class __val_expr; - template friend class _LIBCPP_TEMPLATE_VIS valarray; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS valarray; }; template @@ -1072,12 +1072,12 @@ void resize(size_t __n, value_type __x = value_type()); private: - template friend class _LIBCPP_TEMPLATE_VIS valarray; - template friend class _LIBCPP_TEMPLATE_VIS slice_array; - template friend class _LIBCPP_TEMPLATE_VIS gslice_array; - template friend class _LIBCPP_TEMPLATE_VIS mask_array; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS valarray; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS slice_array; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS gslice_array; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS mask_array; template friend class __mask_expr; - template friend class _LIBCPP_TEMPLATE_VIS indirect_array; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS indirect_array; template friend class __indirect_expr; template friend class __val_expr; @@ -2644,7 +2644,7 @@ size_t size() const {return __1d_.size();} template friend class __val_expr; - template friend class _LIBCPP_TEMPLATE_VIS valarray; + template friend class _LIBCPP_FRIEND_TEMPLATE_VIS valarray; }; template diff --git a/libcxx/include/vector b/libcxx/include/vector --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -2429,7 +2429,7 @@ friend class __bit_iterator; friend class __bit_iterator; friend struct __bit_array; - friend struct _LIBCPP_TEMPLATE_VIS hash; + friend struct _LIBCPP_FRIEND_TEMPLATE_VIS hash; }; template