Skip to content

Commit 0a13175

Browse files
authored
[libc++] Adds a global private constructor tag. (#87920)
This removes the similar tags used in the chrono tzdb implementation. Fixes: #85432
1 parent 2b00a73 commit 0a13175

File tree

20 files changed

+79
-103
lines changed

20 files changed

+79
-103
lines changed

libcxx/include/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,7 @@ set(files
863863
__utility/pair.h
864864
__utility/piecewise_construct.h
865865
__utility/priority_tag.h
866+
__utility/private_constructor_tag.h
866867
__utility/rel_ops.h
867868
__utility/small_buffer.h
868869
__utility/swap.h

libcxx/include/__chrono/leap_second.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
# include <__compare/ordering.h>
2323
# include <__compare/three_way_comparable.h>
2424
# include <__config>
25+
# include <__utility/private_constructor_tag.h>
2526

2627
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2728
# pragma GCC system_header
@@ -35,9 +36,8 @@ namespace chrono {
3536

3637
class leap_second {
3738
public:
38-
struct __constructor_tag;
3939
[[nodiscard]]
40-
_LIBCPP_HIDE_FROM_ABI explicit constexpr leap_second(__constructor_tag&&, sys_seconds __date, seconds __value)
40+
_LIBCPP_HIDE_FROM_ABI explicit constexpr leap_second(__private_constructor_tag, sys_seconds __date, seconds __value)
4141
: __date_(__date), __value_(__value) {}
4242

4343
_LIBCPP_HIDE_FROM_ABI leap_second(const leap_second&) = default;

libcxx/include/__chrono/time_zone_link.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
# include <__compare/strong_order.h>
2020
# include <__config>
21+
# include <__utility/private_constructor_tag.h>
2122
# include <string>
2223
# include <string_view>
2324

@@ -37,9 +38,8 @@ namespace chrono {
3738

3839
class time_zone_link {
3940
public:
40-
struct __constructor_tag;
4141
_LIBCPP_NODISCARD_EXT
42-
_LIBCPP_HIDE_FROM_ABI explicit time_zone_link(__constructor_tag&&, string_view __name, string_view __target)
42+
_LIBCPP_HIDE_FROM_ABI explicit time_zone_link(__private_constructor_tag, string_view __name, string_view __target)
4343
: __name_{__name}, __target_{__target} {}
4444

4545
_LIBCPP_HIDE_FROM_ABI time_zone_link(time_zone_link&&) = default;

libcxx/include/__locale

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <__mutex/once_flag.h>
1717
#include <__type_traits/make_unsigned.h>
1818
#include <__utility/no_destroy.h>
19+
#include <__utility/private_constructor_tag.h>
1920
#include <cctype>
2021
#include <clocale>
2122
#include <cstdint>
@@ -97,8 +98,7 @@ private:
9798

9899
template <class>
99100
friend struct __no_destroy;
100-
struct __private_tag {};
101-
_LIBCPP_HIDE_FROM_ABI explicit locale(__private_tag, __imp* __loc) : __locale_(__loc) {}
101+
_LIBCPP_HIDE_FROM_ABI explicit locale(__private_constructor_tag, __imp* __loc) : __locale_(__loc) {}
102102

103103
void __install_ctor(const locale&, facet*, long);
104104
static locale& __global();
@@ -1248,10 +1248,10 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char
12481248
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
12491249
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>;
12501250
#endif
1251-
extern template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
1252-
codecvt_byname<char16_t, char, mbstate_t>; // deprecated in C++20
1253-
extern template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
1254-
codecvt_byname<char32_t, char, mbstate_t>; // deprecated in C++20
1251+
extern template class _LIBCPP_DEPRECATED_IN_CXX20
1252+
_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>; // deprecated in C++20
1253+
extern template class _LIBCPP_DEPRECATED_IN_CXX20
1254+
_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>; // deprecated in C++20
12551255
#ifndef _LIBCPP_HAS_NO_CHAR8_T
12561256
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char8_t, mbstate_t>; // C++20
12571257
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>; // C++20

libcxx/include/__stop_token/stop_callback.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <__type_traits/is_nothrow_constructible.h>
2222
#include <__utility/forward.h>
2323
#include <__utility/move.h>
24+
#include <__utility/private_constructor_tag.h>
2425

2526
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2627
# pragma GCC system_header
@@ -49,13 +50,13 @@ class _LIBCPP_AVAILABILITY_SYNC stop_callback : private __stop_callback_base {
4950
requires constructible_from<_Callback, _Cb>
5051
_LIBCPP_HIDE_FROM_ABI explicit stop_callback(const stop_token& __st,
5152
_Cb&& __cb) noexcept(is_nothrow_constructible_v<_Callback, _Cb>)
52-
: stop_callback(__private_tag{}, __st.__state_, std::forward<_Cb>(__cb)) {}
53+
: stop_callback(__private_constructor_tag{}, __st.__state_, std::forward<_Cb>(__cb)) {}
5354

5455
template <class _Cb>
5556
requires constructible_from<_Callback, _Cb>
5657
_LIBCPP_HIDE_FROM_ABI explicit stop_callback(stop_token&& __st,
5758
_Cb&& __cb) noexcept(is_nothrow_constructible_v<_Callback, _Cb>)
58-
: stop_callback(__private_tag{}, std::move(__st.__state_), std::forward<_Cb>(__cb)) {}
59+
: stop_callback(__private_constructor_tag{}, std::move(__st.__state_), std::forward<_Cb>(__cb)) {}
5960

6061
_LIBCPP_HIDE_FROM_ABI ~stop_callback() {
6162
if (__state_) {
@@ -74,10 +75,8 @@ class _LIBCPP_AVAILABILITY_SYNC stop_callback : private __stop_callback_base {
7475

7576
friend __stop_callback_base;
7677

77-
struct __private_tag {};
78-
7978
template <class _StatePtr, class _Cb>
80-
_LIBCPP_HIDE_FROM_ABI explicit stop_callback(__private_tag, _StatePtr&& __state, _Cb&& __cb) noexcept(
79+
_LIBCPP_HIDE_FROM_ABI explicit stop_callback(__private_constructor_tag, _StatePtr&& __state, _Cb&& __cb) noexcept(
8180
is_nothrow_constructible_v<_Callback, _Cb>)
8281
: __stop_callback_base([](__stop_callback_base* __cb_base) noexcept {
8382
// stop callback is supposed to only be called once
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// -*- C++ -*-
2+
//===----------------------------------------------------------------------===//
3+
//
4+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5+
// See https://llvm.org/LICENSE.txt for license information.
6+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#ifndef _LIBCPP__UTILITY_PRIVATE_CONSTRUCTOR_TAG_H
11+
#define _LIBCPP__UTILITY_PRIVATE_CONSTRUCTOR_TAG_H
12+
13+
#include <__config>
14+
15+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16+
# pragma GCC system_header
17+
#endif
18+
19+
_LIBCPP_BEGIN_NAMESPACE_STD
20+
21+
// This tag allows defining non-standard exposition-only constructors while
22+
// preventing users from being able to use them, since this reserved-name tag
23+
// needs to be used.
24+
struct __private_constructor_tag {};
25+
26+
_LIBCPP_END_NAMESPACE_STD
27+
28+
#endif // _LIBCPP__UTILITY_PRIVATE_CONSTRUCTOR_TAG_H

libcxx/include/module.modulemap

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2090,18 +2090,19 @@ module std_private_utility_pair [system] {
20902090
export std_private_type_traits_is_nothrow_move_assignable
20912091
export std_private_utility_pair_fwd
20922092
}
2093-
module std_private_utility_pair_fwd [system] { header "__fwd/pair.h" }
2094-
module std_private_utility_piecewise_construct [system] { header "__utility/piecewise_construct.h" }
2095-
module std_private_utility_priority_tag [system] { header "__utility/priority_tag.h" }
2096-
module std_private_utility_rel_ops [system] { header "__utility/rel_ops.h" }
2097-
module std_private_utility_small_buffer [system] { header "__utility/small_buffer.h" }
2098-
module std_private_utility_swap [system] {
2093+
module std_private_utility_pair_fwd [system] { header "__fwd/pair.h" }
2094+
module std_private_utility_piecewise_construct [system] { header "__utility/piecewise_construct.h" }
2095+
module std_private_utility_priority_tag [system] { header "__utility/priority_tag.h" }
2096+
module std_private_utility_private_constructor_tag [system] { header "__utility/private_constructor_tag.h" }
2097+
module std_private_utility_rel_ops [system] { header "__utility/rel_ops.h" }
2098+
module std_private_utility_small_buffer [system] { header "__utility/small_buffer.h" }
2099+
module std_private_utility_swap [system] {
20992100
header "__utility/swap.h"
21002101
export std_private_type_traits_is_swappable
21012102
}
2102-
module std_private_utility_to_underlying [system] { header "__utility/to_underlying.h" }
2103-
module std_private_utility_unreachable [system] { header "__utility/unreachable.h" }
2103+
module std_private_utility_to_underlying [system] { header "__utility/to_underlying.h" }
2104+
module std_private_utility_unreachable [system] { header "__utility/unreachable.h" }
21042105

2105-
module std_private_variant_monostate [system] { header "__variant/monostate.h" }
2106+
module std_private_variant_monostate [system] { header "__variant/monostate.h" }
21062107

2107-
module std_private_vector_fwd [system] { header "__fwd/vector.h" }
2108+
module std_private_vector_fwd [system] { header "__fwd/vector.h" }

libcxx/src/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,6 @@ endif()
334334

335335
if (LIBCXX_ENABLE_LOCALIZATION AND LIBCXX_ENABLE_FILESYSTEM AND LIBCXX_ENABLE_TIME_ZONE_DATABASE)
336336
list(APPEND LIBCXX_EXPERIMENTAL_SOURCES
337-
include/tzdb/leap_second_private.h
338-
include/tzdb/time_zone_link_private.h
339337
include/tzdb/time_zone_private.h
340338
include/tzdb/types_private.h
341339
include/tzdb/tzdb_list_private.h

libcxx/src/include/tzdb/leap_second_private.h

Lines changed: 0 additions & 27 deletions
This file was deleted.

libcxx/src/include/tzdb/time_zone_link_private.h

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)