-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[libc++] Remove the need for _LIBCPP_TEMPLATE_VIS #133010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[libc++] Remove the need for _LIBCPP_TEMPLATE_VIS #133010
Conversation
You can test this locally with the following command:git-clang-format --diff a0206b1236cb9fd0aa5ef5693e92991ee76d2c31 7caa8131c7398248090589e9cbbddd51d61570b1 --extensions ,h -- libcxx/include/__chrono/duration.h libcxx/include/__chrono/formatter.h libcxx/include/__chrono/parser_std_format_spec.h libcxx/include/__chrono/time_point.h libcxx/include/__compare/common_comparison_category.h libcxx/include/__compare/compare_three_way.h libcxx/include/__compare/compare_three_way_result.h libcxx/include/__config libcxx/include/__coroutine/coroutine_handle.h libcxx/include/__coroutine/noop_coroutine_handle.h libcxx/include/__format/buffer.h libcxx/include/__format/container_adaptor.h libcxx/include/__format/format_arg.h libcxx/include/__format/format_arg_store.h libcxx/include/__format/format_args.h libcxx/include/__format/format_context.h libcxx/include/__format/format_functions.h libcxx/include/__format/format_parse_context.h libcxx/include/__format/format_string.h libcxx/include/__format/format_to_n_result.h libcxx/include/__format/formatter.h libcxx/include/__format/formatter_bool.h libcxx/include/__format/formatter_char.h libcxx/include/__format/formatter_floating_point.h libcxx/include/__format/formatter_integer.h libcxx/include/__format/formatter_integral.h libcxx/include/__format/formatter_pointer.h libcxx/include/__format/formatter_string.h libcxx/include/__format/formatter_tuple.h libcxx/include/__format/parser_std_format_spec.h libcxx/include/__format/range_default_formatter.h libcxx/include/__format/range_formatter.h libcxx/include/__functional/binary_function.h libcxx/include/__functional/binary_negate.h libcxx/include/__functional/binder1st.h libcxx/include/__functional/binder2nd.h libcxx/include/__functional/boyer_moore_searcher.h libcxx/include/__functional/default_searcher.h libcxx/include/__functional/function.h libcxx/include/__functional/hash.h libcxx/include/__functional/mem_fun_ref.h libcxx/include/__functional/operations.h libcxx/include/__functional/pointer_to_binary_function.h libcxx/include/__functional/pointer_to_unary_function.h libcxx/include/__functional/reference_wrapper.h libcxx/include/__functional/unary_function.h libcxx/include/__functional/unary_negate.h libcxx/include/__fwd/array.h libcxx/include/__fwd/complex.h libcxx/include/__fwd/deque.h libcxx/include/__fwd/format.h libcxx/include/__fwd/fstream.h libcxx/include/__fwd/functional.h libcxx/include/__fwd/ios.h libcxx/include/__fwd/istream.h libcxx/include/__fwd/map.h libcxx/include/__fwd/memory.h libcxx/include/__fwd/memory_resource.h libcxx/include/__fwd/ostream.h libcxx/include/__fwd/pair.h libcxx/include/__fwd/queue.h libcxx/include/__fwd/set.h libcxx/include/__fwd/sstream.h libcxx/include/__fwd/stack.h libcxx/include/__fwd/streambuf.h libcxx/include/__fwd/string.h libcxx/include/__fwd/string_view.h libcxx/include/__fwd/subrange.h libcxx/include/__fwd/tuple.h libcxx/include/__fwd/variant.h libcxx/include/__fwd/vector.h libcxx/include/__hash_table libcxx/include/__ios/fpos.h libcxx/include/__iterator/back_insert_iterator.h libcxx/include/__iterator/front_insert_iterator.h libcxx/include/__iterator/insert_iterator.h libcxx/include/__iterator/istream_iterator.h libcxx/include/__iterator/istreambuf_iterator.h libcxx/include/__iterator/iterator.h libcxx/include/__iterator/iterator_traits.h libcxx/include/__iterator/move_iterator.h libcxx/include/__iterator/move_sentinel.h libcxx/include/__iterator/ostream_iterator.h libcxx/include/__iterator/ostreambuf_iterator.h libcxx/include/__iterator/reverse_iterator.h libcxx/include/__iterator/wrap_iter.h libcxx/include/__locale libcxx/include/__memory/allocator.h libcxx/include/__memory/allocator_arg_t.h libcxx/include/__memory/allocator_traits.h libcxx/include/__memory/auto_ptr.h libcxx/include/__memory/inout_ptr.h libcxx/include/__memory/out_ptr.h libcxx/include/__memory/pointer_traits.h libcxx/include/__memory/raw_storage_iterator.h libcxx/include/__memory/shared_ptr.h libcxx/include/__memory/unique_ptr.h libcxx/include/__memory/uses_allocator.h libcxx/include/__memory_resource/polymorphic_allocator.h libcxx/include/__mutex/lock_guard.h libcxx/include/__mutex/once_flag.h libcxx/include/__mutex/unique_lock.h libcxx/include/__node_handle libcxx/include/__ostream/basic_ostream.h libcxx/include/__random/bernoulli_distribution.h libcxx/include/__random/binomial_distribution.h libcxx/include/__random/cauchy_distribution.h libcxx/include/__random/chi_squared_distribution.h libcxx/include/__random/discard_block_engine.h libcxx/include/__random/discrete_distribution.h libcxx/include/__random/exponential_distribution.h libcxx/include/__random/extreme_value_distribution.h libcxx/include/__random/fisher_f_distribution.h libcxx/include/__random/gamma_distribution.h libcxx/include/__random/geometric_distribution.h libcxx/include/__random/independent_bits_engine.h libcxx/include/__random/linear_congruential_engine.h libcxx/include/__random/lognormal_distribution.h libcxx/include/__random/mersenne_twister_engine.h libcxx/include/__random/negative_binomial_distribution.h libcxx/include/__random/normal_distribution.h libcxx/include/__random/piecewise_constant_distribution.h libcxx/include/__random/piecewise_linear_distribution.h libcxx/include/__random/poisson_distribution.h libcxx/include/__random/seed_seq.h libcxx/include/__random/shuffle_order_engine.h libcxx/include/__random/student_t_distribution.h libcxx/include/__random/subtract_with_carry_engine.h libcxx/include/__random/uniform_real_distribution.h libcxx/include/__random/weibull_distribution.h libcxx/include/__ranges/non_propagating_cache.h libcxx/include/__ranges/subrange.h libcxx/include/__string/char_traits.h libcxx/include/__system_error/error_code.h libcxx/include/__system_error/error_condition.h libcxx/include/__thread/formatter.h libcxx/include/__thread/id.h libcxx/include/__thread/thread.h libcxx/include/__tree libcxx/include/__tuple/sfinae_helpers.h libcxx/include/__tuple/tuple_element.h libcxx/include/__tuple/tuple_size.h libcxx/include/__type_traits/add_cv_quals.h libcxx/include/__type_traits/aligned_storage.h libcxx/include/__type_traits/alignment_of.h libcxx/include/__type_traits/common_type.h libcxx/include/__type_traits/conditional.h libcxx/include/__type_traits/decay.h libcxx/include/__type_traits/dependent_type.h libcxx/include/__type_traits/enable_if.h libcxx/include/__type_traits/extent.h libcxx/include/__type_traits/has_unique_object_representation.h libcxx/include/__type_traits/has_virtual_destructor.h libcxx/include/__type_traits/integral_constant.h libcxx/include/__type_traits/invoke.h libcxx/include/__type_traits/is_abstract.h libcxx/include/__type_traits/is_aggregate.h libcxx/include/__type_traits/is_arithmetic.h libcxx/include/__type_traits/is_array.h libcxx/include/__type_traits/is_assignable.h libcxx/include/__type_traits/is_base_of.h libcxx/include/__type_traits/is_bounded_array.h libcxx/include/__type_traits/is_class.h libcxx/include/__type_traits/is_compound.h libcxx/include/__type_traits/is_const.h libcxx/include/__type_traits/is_constructible.h libcxx/include/__type_traits/is_convertible.h libcxx/include/__type_traits/is_destructible.h libcxx/include/__type_traits/is_empty.h libcxx/include/__type_traits/is_enum.h libcxx/include/__type_traits/is_final.h libcxx/include/__type_traits/is_floating_point.h libcxx/include/__type_traits/is_function.h libcxx/include/__type_traits/is_fundamental.h libcxx/include/__type_traits/is_implicit_lifetime.h libcxx/include/__type_traits/is_integral.h libcxx/include/__type_traits/is_literal_type.h libcxx/include/__type_traits/is_member_pointer.h libcxx/include/__type_traits/is_nothrow_assignable.h libcxx/include/__type_traits/is_nothrow_constructible.h libcxx/include/__type_traits/is_nothrow_destructible.h libcxx/include/__type_traits/is_null_pointer.h libcxx/include/__type_traits/is_object.h libcxx/include/__type_traits/is_pod.h libcxx/include/__type_traits/is_pointer.h libcxx/include/__type_traits/is_polymorphic.h libcxx/include/__type_traits/is_reference.h libcxx/include/__type_traits/is_same.h libcxx/include/__type_traits/is_scalar.h libcxx/include/__type_traits/is_signed.h libcxx/include/__type_traits/is_standard_layout.h libcxx/include/__type_traits/is_swappable.h libcxx/include/__type_traits/is_trivial.h libcxx/include/__type_traits/is_trivially_assignable.h libcxx/include/__type_traits/is_trivially_constructible.h libcxx/include/__type_traits/is_trivially_copyable.h libcxx/include/__type_traits/is_trivially_destructible.h libcxx/include/__type_traits/is_unbounded_array.h libcxx/include/__type_traits/is_union.h libcxx/include/__type_traits/is_unsigned.h libcxx/include/__type_traits/is_void.h libcxx/include/__type_traits/is_volatile.h libcxx/include/__type_traits/rank.h libcxx/include/__type_traits/reference_constructs_from_temporary.h libcxx/include/__type_traits/reference_converts_from_temporary.h libcxx/include/__type_traits/remove_all_extents.h libcxx/include/__type_traits/remove_const.h libcxx/include/__type_traits/remove_extent.h libcxx/include/__type_traits/remove_pointer.h libcxx/include/__type_traits/remove_volatile.h libcxx/include/__type_traits/result_of.h libcxx/include/__utility/in_place.h libcxx/include/__utility/integer_sequence.h libcxx/include/__utility/pair.h libcxx/include/__utility/piecewise_construct.h libcxx/include/__variant/monostate.h libcxx/include/__vector/vector.h libcxx/include/__vector/vector_bool.h libcxx/include/__vector/vector_bool_formatter.h libcxx/include/any libcxx/include/array libcxx/include/bitset libcxx/include/codecvt libcxx/include/complex libcxx/include/deque libcxx/include/experimental/type_traits libcxx/include/experimental/utility libcxx/include/ext/__hash libcxx/include/ext/hash_map libcxx/include/ext/hash_set libcxx/include/forward_list libcxx/include/fstream libcxx/include/future libcxx/include/initializer_list libcxx/include/ios libcxx/include/iosfwd libcxx/include/istream libcxx/include/limits libcxx/include/list libcxx/include/locale libcxx/include/map libcxx/include/mutex libcxx/include/optional libcxx/include/queue libcxx/include/ratio libcxx/include/regex libcxx/include/scoped_allocator libcxx/include/set libcxx/include/span libcxx/include/sstream libcxx/include/stack libcxx/include/streambuf libcxx/include/syncstream libcxx/include/tuple libcxx/include/typeindex libcxx/include/unordered_map libcxx/include/unordered_set libcxx/include/valarray libcxx/include/variantView the diff from clang-format here.diff --git a/libcxx/include/__format/format_context.h b/libcxx/include/__format/format_context.h
index ccf5084d53..e672ee7ad0 100644
--- a/libcxx/include/__format/format_context.h
+++ b/libcxx/include/__format/format_context.h
@@ -72,8 +72,8 @@ using wformat_context = basic_format_context< back_insert_iterator<__format::__o
template <class _OutIt, class _CharT>
requires output_iterator<_OutIt, const _CharT&>
-class _LIBCPP_PREFERRED_NAME(format_context) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wformat_context))
- basic_format_context {
+class _LIBCPP_PREFERRED_NAME(format_context)
+ _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wformat_context)) basic_format_context {
public:
using iterator = _OutIt;
using char_type = _CharT;
diff --git a/libcxx/include/__format/formatter_string.h b/libcxx/include/__format/formatter_string.h
index 65ca76c22f..d71d19a497 100644
--- a/libcxx/include/__format/formatter_string.h
+++ b/libcxx/include/__format/formatter_string.h
@@ -100,8 +100,7 @@ struct formatter<_CharT[_Size], _CharT> : public __formatter_string<_CharT> {
// Formatter std::string.
template <__fmt_char_type _CharT, class _Traits, class _Allocator>
-struct formatter<basic_string<_CharT, _Traits, _Allocator>, _CharT>
- : public __formatter_string<_CharT> {
+struct formatter<basic_string<_CharT, _Traits, _Allocator>, _CharT> : public __formatter_string<_CharT> {
using _Base _LIBCPP_NODEBUG = __formatter_string<_CharT>;
template <class _FormatContext>
diff --git a/libcxx/include/__functional/binder1st.h b/libcxx/include/__functional/binder1st.h
index 713a05327a..77a0322450 100644
--- a/libcxx/include/__functional/binder1st.h
+++ b/libcxx/include/__functional/binder1st.h
@@ -22,8 +22,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
template <class _Operation>
-class _LIBCPP_DEPRECATED_IN_CXX11
-binder1st : public __unary_function<typename _Operation::second_argument_type, typename _Operation::result_type> {
+class _LIBCPP_DEPRECATED_IN_CXX11 binder1st
+ : public __unary_function<typename _Operation::second_argument_type, typename _Operation::result_type> {
protected:
_Operation op;
typename _Operation::first_argument_type value;
diff --git a/libcxx/include/__functional/binder2nd.h b/libcxx/include/__functional/binder2nd.h
index 73b0fea0f0..8cc644151a 100644
--- a/libcxx/include/__functional/binder2nd.h
+++ b/libcxx/include/__functional/binder2nd.h
@@ -22,8 +22,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
template <class _Operation>
-class _LIBCPP_DEPRECATED_IN_CXX11
-binder2nd : public __unary_function<typename _Operation::first_argument_type, typename _Operation::result_type> {
+class _LIBCPP_DEPRECATED_IN_CXX11 binder2nd
+ : public __unary_function<typename _Operation::first_argument_type, typename _Operation::result_type> {
protected:
_Operation op;
typename _Operation::second_argument_type value;
diff --git a/libcxx/include/regex b/libcxx/include/regex
index 0ab50b5c8e..2c732ead45 100644
--- a/libcxx/include/regex
+++ b/libcxx/include/regex
@@ -5331,8 +5331,8 @@ typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
template <class _BidirectionalIterator, class _CharT, class _Traits>
class _LIBCPP_PREFERRED_NAME(cregex_iterator) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcregex_iterator))
- _LIBCPP_PREFERRED_NAME(sregex_iterator) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wsregex_iterator))
- regex_iterator {
+ _LIBCPP_PREFERRED_NAME(sregex_iterator)
+ _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wsregex_iterator)) regex_iterator {
public:
typedef basic_regex<_CharT, _Traits> regex_type;
typedef match_results<_BidirectionalIterator> value_type;
|
a761840 to
7caa813
Compare
|
@llvm/pr-subscribers-libcxx Author: Nikolas Klauser (philnik777) ChangesSince almost all of our symbols are explicitly annotated with visibility macros, this makes almost no difference to the actual visibility of symbols. Not having to annotate types at the cost of having a few more symbols with default visibility on GCC seems like the right choice to me. Patch is 322.31 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/133010.diff 261 Files Affected:
diff --git a/libcxx/.clang-format b/libcxx/.clang-format
index f548119652c19..7dcb72cde72a7 100644
--- a/libcxx/.clang-format
+++ b/libcxx/.clang-format
@@ -45,7 +45,6 @@ AttributeMacros: [
'_LIBCPP_OVERRIDABLE_FUNC_VIS',
'_LIBCPP_STANDALONE_DEBUG',
'_LIBCPP_TEMPLATE_DATA_VIS',
- '_LIBCPP_TEMPLATE_VIS',
'_LIBCPP_THREAD_SAFETY_ANNOTATION',
'_LIBCPP_USING_IF_EXISTS',
'_LIBCPP_WEAK',
diff --git a/libcxx/docs/DesignDocs/VisibilityMacros.rst b/libcxx/docs/DesignDocs/VisibilityMacros.rst
index 83a9a62942bc9..0c1b4e976f2b6 100644
--- a/libcxx/docs/DesignDocs/VisibilityMacros.rst
+++ b/libcxx/docs/DesignDocs/VisibilityMacros.rst
@@ -64,25 +64,13 @@ Visibility Macros
ABI, we should create a new _LIBCPP_HIDE_FROM_ABI_AFTER_XXX macro, and we can
use it to start removing symbols from the ABI after that stable version.
-**_LIBCPP_TEMPLATE_VIS**
- Mark a type's typeinfo and vtable as having default visibility.
- This macro has no effect on the visibility of the type's member functions.
-
- **GCC Behavior**: GCC does not support Clang's `type_visibility(...)`
- attribute. With GCC the `visibility(...)` attribute is used and member
- functions are affected.
-
- **Windows Behavior**: DLLs do not support dllimport/export on class templates.
- The macro has an empty definition on this platform.
-
**_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS**
Mark the member functions, typeinfo, and vtable of the type named in
an extern template declaration as being exported by the libc++ library.
This attribute must be specified on all extern class template declarations.
- This macro is used to override the `_LIBCPP_TEMPLATE_VIS` attribute
- specified on the primary template and to export the member functions produced
- by the explicit instantiation in the dylib.
+ This macro is used to export the member functions produced by the explicit
+ instantiation in the dylib.
**Windows Behavior**: `extern template` and `dllexport` are fundamentally
incompatible *on a class template* on Windows; the former suppresses
diff --git a/libcxx/include/__chrono/duration.h b/libcxx/include/__chrono/duration.h
index 941aca6009599..57fa64d650068 100644
--- a/libcxx/include/__chrono/duration.h
+++ b/libcxx/include/__chrono/duration.h
@@ -32,7 +32,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
namespace chrono {
template <class _Rep, class _Period = ratio<1> >
-class _LIBCPP_TEMPLATE_VIS duration;
+class duration;
template <class _Tp>
inline const bool __is_duration_v = false;
@@ -52,7 +52,7 @@ inline const bool __is_duration_v<const volatile duration<_Rep, _Period> > = tru
} // namespace chrono
template <class _Rep1, class _Period1, class _Rep2, class _Period2>
-struct _LIBCPP_TEMPLATE_VIS common_type<chrono::duration<_Rep1, _Period1>, chrono::duration<_Rep2, _Period2> > {
+struct common_type<chrono::duration<_Rep1, _Period1>, chrono::duration<_Rep2, _Period2> > {
typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type, __ratio_gcd<_Period1, _Period2> > type;
};
@@ -107,7 +107,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration duration_cast(const d
}
template <class _Rep>
-struct _LIBCPP_TEMPLATE_VIS treat_as_floating_point : is_floating_point<_Rep> {};
+struct treat_as_floating_point : is_floating_point<_Rep> {};
#if _LIBCPP_STD_VER >= 17
template <class _Rep>
@@ -115,7 +115,7 @@ inline constexpr bool treat_as_floating_point_v = treat_as_floating_point<_Rep>:
#endif
template <class _Rep>
-struct _LIBCPP_TEMPLATE_VIS duration_values {
+struct duration_values {
public:
_LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR _Rep zero() _NOEXCEPT { return _Rep(0); }
_LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR _Rep max() _NOEXCEPT { return numeric_limits<_Rep>::max(); }
@@ -156,7 +156,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration round(const duration<
// duration
template <class _Rep, class _Period>
-class _LIBCPP_TEMPLATE_VIS duration {
+class duration {
static_assert(!__is_duration_v<_Rep>, "A duration representation can not be a duration");
static_assert(__is_ratio_v<_Period>, "Second template parameter of duration must be a std::ratio");
static_assert(_Period::num > 0, "duration period must be positive");
diff --git a/libcxx/include/__chrono/formatter.h b/libcxx/include/__chrono/formatter.h
index 7b081f92667b5..86b606d27847b 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -698,7 +698,7 @@ __format_chrono(const _Tp& __value,
} // namespace __formatter
template <__fmt_char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS __formatter_chrono {
+struct __formatter_chrono {
public:
template <class _ParseContext>
_LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator
@@ -716,7 +716,7 @@ struct _LIBCPP_TEMPLATE_VIS __formatter_chrono {
};
template <class _Duration, __fmt_char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS formatter<chrono::sys_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {
+struct formatter<chrono::sys_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {
public:
using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
@@ -730,7 +730,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<chrono::sys_time<_Duration>, _CharT> : pub
# if _LIBCPP_HAS_EXPERIMENTAL_TZDB
template <class _Duration, __fmt_char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS formatter<chrono::utc_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {
+struct formatter<chrono::utc_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {
public:
using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
@@ -741,7 +741,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<chrono::utc_time<_Duration>, _CharT> : pub
};
template <class _Duration, __fmt_char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS formatter<chrono::tai_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {
+struct formatter<chrono::tai_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {
public:
using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
@@ -752,7 +752,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<chrono::tai_time<_Duration>, _CharT> : pub
};
template <class _Duration, __fmt_char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS formatter<chrono::gps_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {
+struct formatter<chrono::gps_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {
public:
using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
@@ -766,7 +766,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<chrono::gps_time<_Duration>, _CharT> : pub
# endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
template <class _Duration, __fmt_char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS formatter<chrono::file_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {
+struct formatter<chrono::file_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {
public:
using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
@@ -777,7 +777,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<chrono::file_time<_Duration>, _CharT> : pu
};
template <class _Duration, __fmt_char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS formatter<chrono::local_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {
+struct formatter<chrono::local_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {
public:
using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
@@ -811,7 +811,7 @@ struct formatter<chrono::duration<_Rep, _Period>, _CharT> : public __formatter_c
};
template <__fmt_char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS formatter<chrono::day, _CharT> : public __formatter_chrono<_CharT> {
+struct formatter<chrono::day, _CharT> : public __formatter_chrono<_CharT> {
public:
using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
@@ -822,7 +822,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<chrono::day, _CharT> : public __formatter_
};
template <__fmt_char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month, _CharT> : public __formatter_chrono<_CharT> {
+struct formatter<chrono::month, _CharT> : public __formatter_chrono<_CharT> {
public:
using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
@@ -833,7 +833,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month, _CharT> : public __formatte
};
template <__fmt_char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year, _CharT> : public __formatter_chrono<_CharT> {
+struct formatter<chrono::year, _CharT> : public __formatter_chrono<_CharT> {
public:
using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
@@ -844,7 +844,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year, _CharT> : public __formatter
};
template <__fmt_char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS formatter<chrono::weekday, _CharT> : public __formatter_chrono<_CharT> {
+struct formatter<chrono::weekday, _CharT> : public __formatter_chrono<_CharT> {
public:
using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
@@ -855,7 +855,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<chrono::weekday, _CharT> : public __format
};
template <__fmt_char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS formatter<chrono::weekday_indexed, _CharT> : public __formatter_chrono<_CharT> {
+struct formatter<chrono::weekday_indexed, _CharT> : public __formatter_chrono<_CharT> {
public:
using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
@@ -866,7 +866,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<chrono::weekday_indexed, _CharT> : public
};
template <__fmt_char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS formatter<chrono::weekday_last, _CharT> : public __formatter_chrono<_CharT> {
+struct formatter<chrono::weekday_last, _CharT> : public __formatter_chrono<_CharT> {
public:
using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
@@ -877,7 +877,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<chrono::weekday_last, _CharT> : public __f
};
template <__fmt_char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_day, _CharT> : public __formatter_chrono<_CharT> {
+struct formatter<chrono::month_day, _CharT> : public __formatter_chrono<_CharT> {
public:
using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
@@ -888,7 +888,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_day, _CharT> : public __form
};
template <__fmt_char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_day_last, _CharT> : public __formatter_chrono<_CharT> {
+struct formatter<chrono::month_day_last, _CharT> : public __formatter_chrono<_CharT> {
public:
using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
@@ -899,7 +899,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_day_last, _CharT> : public _
};
template <__fmt_char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_weekday, _CharT> : public __formatter_chrono<_CharT> {
+struct formatter<chrono::month_weekday, _CharT> : public __formatter_chrono<_CharT> {
public:
using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
@@ -910,7 +910,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_weekday, _CharT> : public __
};
template <__fmt_char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_weekday_last, _CharT> : public __formatter_chrono<_CharT> {
+struct formatter<chrono::month_weekday_last, _CharT> : public __formatter_chrono<_CharT> {
public:
using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
@@ -921,7 +921,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_weekday_last, _CharT> : publ
};
template <__fmt_char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month, _CharT> : public __formatter_chrono<_CharT> {
+struct formatter<chrono::year_month, _CharT> : public __formatter_chrono<_CharT> {
public:
using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
@@ -932,7 +932,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month, _CharT> : public __for
};
template <__fmt_char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_day, _CharT> : public __formatter_chrono<_CharT> {
+struct formatter<chrono::year_month_day, _CharT> : public __formatter_chrono<_CharT> {
public:
using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
@@ -943,7 +943,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_day, _CharT> : public _
};
template <__fmt_char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_day_last, _CharT> : public __formatter_chrono<_CharT> {
+struct formatter<chrono::year_month_day_last, _CharT> : public __formatter_chrono<_CharT> {
public:
using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
@@ -954,7 +954,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_day_last, _CharT> : pub
};
template <__fmt_char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_weekday, _CharT> : public __formatter_chrono<_CharT> {
+struct formatter<chrono::year_month_weekday, _CharT> : public __formatter_chrono<_CharT> {
public:
using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
@@ -965,7 +965,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_weekday, _CharT> : publ
};
template <__fmt_char_type _CharT>
-struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_weekday_last, _CharT> : public __formatter_chrono<_CharT> {
+struct formatter<chrono::year_month_weekday_last, _CharT> : public __formatter_chrono<_CharT> {
public:
using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
diff --git a/libcxx/include/__chrono/parser_std_format_spec.h b/libcxx/include/__chrono/parser_std_format_spec.h
index 4df8e603c6bcf..8ecc19f3c7821 100644
--- a/libcxx/include/__chrono/parser_std_format_spec.h
+++ b/libcxx/include/__chrono/parser_std_format_spec.h
@@ -139,7 +139,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __validate_time_zone(__flags __flags) {
}
template <class _CharT>
-class _LIBCPP_TEMPLATE_VIS __parser_chrono {
+class __parser_chrono {
using _ConstIterator _LIBCPP_NODEBUG = typename basic_format_parse_context<_CharT>::const_iterator;
public:
diff --git a/libcxx/include/__chrono/time_point.h b/libcxx/include/__chrono/time_point.h
index 5e79fa5d257fa..6b866b882f89a 100644
--- a/libcxx/include/__chrono/time_point.h
+++ b/libcxx/include/__chrono/time_point.h
@@ -31,7 +31,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
namespace chrono {
template <class _Clock, class _Duration = typename _Clock::duration>
-class _LIBCPP_TEMPLATE_VIS time_point {
+class time_point {
static_assert(__is_duration_v<_Duration>, "Second template parameter of time_point must be a std::chrono::duration");
public:
@@ -76,8 +76,7 @@ class _LIBCPP_TEMPLATE_VIS time_point {
} // namespace chrono
template <class _Clock, class _Duration1, class _Duration2>
-struct _LIBCPP_TEMPLATE_VIS
-common_type<chrono::time_point<_Clock, _Duration1>, chrono::time_point<_Clock, _Duration2> > {
+struct common_type<chrono::time_point<_Clock, _Duration1>, chrono::time_point<_Clock, _Duration2> > {
typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type;
};
diff --git a/libcxx/include/__compare/common_comparison_category.h b/libcxx/include/__compare/common_comparison_category.h
index a49499ea4198d..eae2ef00624be 100644
--- a/libcxx/include/__compare/common_comparison_category.h
+++ b/libcxx/include/__compare/common_comparison_category.h
@@ -72,7 +72,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __get_comp_type() {
// [cmp.common], common comparison category type
template <class... _Ts>
-struct _LIBCPP_TEMPLATE_VIS common_comparison_category {
+struct common_comparison_category {
using type _LIBCPP_NODEBUG = decltype(__comp_detail::__get_comp_type<_Ts...>());
};
diff --git a/libcxx/include/__compare/compare_three_way.h b/libcxx/include/__compare/compare_three_way.h
index 01c12076c0d73..852c5874c61ca 100644
--- a/libcxx/include/__compare/compare_three_way.h
+++ b/libcxx/include/__compare/compare_three_way.h
@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if _LIBCPP_STD_VER >= 20
-struct _LIBCPP_TEMPLATE_VIS compare_three_way {
+struct compare_three_way {
template <class _T1, class _T2>
requires three_way_comparable_with<_T1, _T2>
constexpr _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
diff --git a/libcxx/include/__compare/compare_three_way_result.h b/libcxx/include/__compare/compare_three_way_result.h
index 5327cc57eb580..264a4d603ca44 100644
--- a/libcxx/include/__compare/compare_three_way_result.h
+++ b/libcxx/include/__compare/compare_three_way_result.h
@@ -34,8 +34,7 @@ struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result<
};
template <class _Tp, class _Up = _Tp>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS compare_three_way_result
- : __compare_three_way_result<_Tp, _Up, void> {};
+struct _LIBCPP_NO_SPECIALIZATIONS compare_three_way_result : __compare_three_way_result<_Tp, _Up, void> {};
template <class _Tp, class _Up = _Tp>
using compare_three_way_result_t = typename compare_three_way_result<_Tp, _Up>::type;
diff --git a/libcxx/include/__config b/libcxx/include/__config
index e75f42d928bc3..9486f0dff7bec 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -389,9 +389,8 @@ typedef __char32_t char32_t;
# define _LIBCPP_HIDDEN
# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
-# define _LIBCPP_TEMPLATE_VIS
# define _LIBCPP_TEMPLATE_DATA_VIS
-# define _LIBCPP_TYPE_VISIBILITY_DEFAULT
+# define _LIBCPP_NAMESPACE_VISIBILITY
# else
@@ -419,17 +418,12 @@ typedef __char32_t char32_t;
# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
# endif
-// GCC doesn't support the type_visibility attribute, so we have to keep the visibility attribute on templates
-# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && !__has_attribute(__type_visibility__)
-# define _LIBCPP_TEMPLATE_VIS __attribute__((__visibility__("default")))
-# else
-# define _LIBCPP_TEMPLATE_VIS
-# endif
-
# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
-# define _LIBCPP_TYPE_VISIBILITY_DEFAULT __attribute__((__type_visibility__("default")))
+# define _LIBCPP_NAMESPACE_VISIBILITY __attribute__((__type_visibility__("default")))
+# elif !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
+# define _LIBCPP_NAMESPACE_VISIBILITY __attribute__((__visibility__("default")))
# else
-# define _LIBCPP_TYPE_VISIBILITY_DEFAULT
+# define _LIBCPP_NAMESPACE_VISIBILITY
# endif
# endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
@@ -579,7 +573,7 @@ typedef __char32_t char32_t;
// clang-format off
# define _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD \
- _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS namespace _LIBCPP_TYPE_VISIBILITY_DEFAULT std {
+ _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS namespace _LIBCPP_NAMESPACE_VISIBILITY std {
# define _LIBCPP_END_UNVERSIONED_NAMESPACE_STD } _LIBCPP_POP_EXTENSION_DIAGNOSTICS
diff --git a/libcxx/include/__coroutine/coroutine_handle.h b/libcxx/include/__coroutine/coroutine_handle.h
index e2cde20498d84..88848544cf6bd 100644
--- a/libcxx/include/__coroutine/coroutine_handle.h
+++ b/libcxx/include/__coroutine/coroutine_handle.h
@@ -28,10 +28,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// [coroutine.handle]
template <class _Promise = void>
-struct _LIBCPP_TEMPLATE_VIS coroutine_handle;
+struct coroutine_handle;
template <>
-struct _LIBCPP_TEMPLATE_VIS coroutine_handle<void> {
+struct coroutine_handle<void> {
public:
// [coroutine.handle.con], construct/reset
constexpr coroutine_handle() noexcept = default;
@@ -93,7 +93,7 @@ operator<=>(coroutine_handle<> __x, coroutine_handle<> __y) noexcept {
}
template <class _Promise>
-struct _LIBCPP_TEMPLATE_VIS coroutine_handle {
+struct coroutine_handle {
public:
// [coroutine.handle.con], construct/reset
constexpr coroutine_handle() noexcept = default;
diff --git a/libcxx/include/__coroutine/noop_coroutine_handle.h b/libcxx/include/__coroutine/noop_coroutine_handle.h
index da13d579604b5..c95d85d5484c4 100644
--- a/libcxx/include/__coroutine/noop_coroutine_handle.h
+++ b/libcxx/include/__coroutine/noop_cor...
[truncated]
|
ldionne
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am fine with the spirit of this patch. I think it needs a release note though since we're making library-wide changes. We don't think those changes are going to affect anyone, but I think it's a nice courtesy to give our users and it doesn't cost us anything to call it out.
Also, I'd like this patch to be split into two. First, the changes that introduce NAMESPACE_VIS and that make TEMPLATE_VIS a no-op. Then, one or two weeks after landing the first patch, we can have a second patch that removes _LIBCPP_TEMPLATE_VIS, which is now a no-op. I think this will simplify things in case we need to revert the patch for an unforeseen reason, and it'll allow people who do wonky stuff (e.g. override _LIBCPP_TEMPLATE_VIS for their own purposes) to apply a temporary workaround while they figure out how not to do something unsupported. Again, that's low cost to us and it'll make things much easier for everyone in case things happen to go wrong, unexpectedly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit message should make it clear that this is a no-op on Clang.
| building libc++), the macro always marks symbols as internal so that programs | ||
| built using new libc++ headers stop relying on symbols that are removed from | ||
| the ABI in a future version. Each time we release a new stable version of the | ||
| ABI, we should create a new _LIBCPP_HIDE_FROM_ABI_AFTER_XXX macro, and we can |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not attached to this line: you should update the Overview at the beginning of this file to reflect the latest state of things.
a0206b1 to
8ed3fb7
Compare
Since almost all of our symbols are explicitly annotated with visibility macros, this makes almost no difference to the actual visibility of symbols. Not having to annotate types at the cost of having a few more symbols with default visibility on GCC seems like the right choice to me.