Skip to content

[libc++] Remove _LIBCPP_TEMPLATE_VIS #134885

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

Merged
merged 1 commit into from
Apr 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion libcxx/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,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',
Expand Down
16 changes: 2 additions & 14 deletions libcxx/docs/DesignDocs/VisibilityMacros.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions libcxx/include/__chrono/duration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
};

Expand Down Expand Up @@ -107,15 +107,15 @@ 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>
inline constexpr bool treat_as_floating_point_v = treat_as_floating_point<_Rep>::value;
#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(); }
Expand Down Expand Up @@ -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");
Expand Down
44 changes: 22 additions & 22 deletions libcxx/include/__chrono/formatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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>;

Expand All @@ -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>;

Expand All @@ -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>;

Expand All @@ -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>;

Expand All @@ -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>;

Expand All @@ -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>;

Expand Down Expand Up @@ -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>;

Expand All @@ -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>;

Expand All @@ -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>;

Expand All @@ -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>;

Expand All @@ -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>;

Expand All @@ -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>;

Expand All @@ -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>;

Expand All @@ -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>;

Expand All @@ -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>;

Expand All @@ -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>;

Expand All @@ -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>;

Expand All @@ -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>;

Expand All @@ -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>;

Expand All @@ -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>;

Expand All @@ -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>;

Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__chrono/parser_std_format_spec.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions libcxx/include/__chrono/time_point.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
};

Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__compare/common_comparison_category.h
Original file line number Diff line number Diff line change
Expand Up @@ -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...>());
};

Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__compare/compare_three_way.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions libcxx/include/__compare/compare_three_way_result.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 0 additions & 5 deletions libcxx/include/__config
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ typedef __char32_t char32_t;
# endif

# define _LIBCPP_HIDDEN
# define _LIBCPP_TEMPLATE_VIS
# define _LIBCPP_TEMPLATE_DATA_VIS
# define _LIBCPP_NAMESPACE_VISIBILITY

Expand All @@ -406,10 +405,6 @@ typedef __char32_t char32_t;
# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_VISIBILITY("default")
# endif

// This is kept to avoid a huge library-wide diff in the first step.
// TODO: Remove this in a follow-up patch
# define _LIBCPP_TEMPLATE_VIS

# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
# define _LIBCPP_NAMESPACE_VISIBILITY __attribute__((__type_visibility__("default")))
# elif !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
Expand Down
6 changes: 3 additions & 3 deletions libcxx/include/__coroutine/coroutine_handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__coroutine/noop_coroutine_handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct noop_coroutine_promise {};

// [coroutine.handle.noop]
template <>
struct _LIBCPP_TEMPLATE_VIS coroutine_handle<noop_coroutine_promise> {
struct coroutine_handle<noop_coroutine_promise> {
public:
// [coroutine.handle.noop.conv], conversion
_LIBCPP_HIDE_FROM_ABI constexpr operator coroutine_handle<>() const noexcept {
Expand Down
Loading
Loading