Skip to content

Commit 02e288f

Browse files
committed
Cleanup + FTM
1 parent 5886710 commit 02e288f

File tree

12 files changed

+115
-75
lines changed

12 files changed

+115
-75
lines changed

libcxx/docs/FeatureTestMacroTable.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,8 @@ Status
336336
---------------------------------------------------------- -----------------
337337
``__cpp_lib_ios_noreplace`` ``202207L``
338338
---------------------------------------------------------- -----------------
339+
``__cpp_lib_is_implicit_lifetime`` ``202302L``
340+
---------------------------------------------------------- -----------------
339341
``__cpp_lib_is_scoped_enum`` ``202011L``
340342
---------------------------------------------------------- -----------------
341343
``__cpp_lib_mdspan`` ``202207L``

libcxx/docs/ReleaseNotes/20.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Implemented Papers
4141
- P2747R2: ``constexpr`` placement new (`Github <https://github.com/llvm/llvm-project/issues/105427>`__)
4242
- P2609R3: Relaxing Ranges Just A Smidge (`Github <https://github.com/llvm/llvm-project/issues/105253>`__)
4343
- P2985R0: A type trait for detecting virtual base classes (`Github <https://github.com/llvm/llvm-project/issues/105432>`__)
44+
- P2674R1: A trait for implicit lifetime types (`Github <https://github.com/llvm/llvm-project/issues/105259>`__)
4445

4546

4647
Improvements and New Features

libcxx/docs/Status/Cxx23Papers.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
"`P2572R1 <https://wg21.link/P2572R1>`__","``std::format`` fill character allowances","2023-02 (Issaquah)","|Complete|","17.0",""
114114
"`P2693R1 <https://wg21.link/P2693R1>`__","Formatting ``thread::id`` and ``stacktrace``","2023-02 (Issaquah)","|Partial|","","The formatter for ``stacktrace`` is not implemented, since ``stacktrace`` is not implemented yet"
115115
"`P2679R2 <https://wg21.link/P2679R2>`__","Fixing ``std::start_lifetime_as`` for arrays","2023-02 (Issaquah)","","",""
116-
"`P2674R1 <https://wg21.link/P2674R1>`__","A trait for implicit lifetime types","2023-02 (Issaquah)","","",""
116+
"`P2674R1 <https://wg21.link/P2674R1>`__","A trait for implicit lifetime types","2023-02 (Issaquah)","|Complete|","20.0",""
117117
"`P2655R3 <https://wg21.link/P2655R3>`__","``common_reference_t`` of ``reference_wrapper`` Should Be a Reference Type","2023-02 (Issaquah)","","",""
118118
"`P2652R2 <https://wg21.link/P2652R2>`__","Disallow User Specialization of ``allocator_traits``","2023-02 (Issaquah)","|Complete|","19.0",""
119119
"`P2787R1 <https://wg21.link/P2787R1>`__","``pmr::generator`` - Promise Types are not Values","2023-02 (Issaquah)","","",""

libcxx/include/__type_traits/is_implicit_lifetime.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,6 @@ struct _LIBCPP_TEMPLATE_VIS is_implicit_lifetime : public bool_constant<__builti
2727
template <class _Tp>
2828
inline constexpr bool is_implicit_lifetime_v = __builtin_is_implicit_lifetime(_Tp);
2929

30-
# else
31-
32-
template <typename _Tp>
33-
struct is_implicit_lifetime
34-
: std::disjunction< std::is_scalar<_Tp>,
35-
std::is_array<_Tp>,
36-
std::is_aggregate<_Tp>,
37-
std::conjunction< std::is_trivially_destructible<_Tp>,
38-
std::disjunction< std::is_trivially_default_constructible<_Tp>,
39-
std::is_trivially_copy_constructible<_Tp>,
40-
std::is_trivially_move_constructible<_Tp>>>> {};
41-
42-
template <class _Tp>
43-
inline constexpr bool is_implicit_lifetime_v = is_implicit_lifetime<_Tp>::value;
44-
4530
# endif
4631
#endif
4732

libcxx/include/module.modulemap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,6 +1944,7 @@ module std_private_type_traits_is_final [system
19441944
module std_private_type_traits_is_floating_point [system] { header "__type_traits/is_floating_point.h" }
19451945
module std_private_type_traits_is_function [system] { header "__type_traits/is_function.h" }
19461946
module std_private_type_traits_is_fundamental [system] { header "__type_traits/is_fundamental.h" }
1947+
module std_private_type_traits_is_implicit_lifetime [system] { header "__type_traits/is_implicit_lifetime.h" }
19471948
module std_private_type_traits_is_implicitly_default_constructible [system] {
19481949
header "__type_traits/is_implicitly_default_constructible.h"
19491950
export std_private_type_traits_integral_constant

libcxx/include/version

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ __cpp_lib_ios_noreplace 202207L <ios>
138138
__cpp_lib_is_aggregate 201703L <type_traits>
139139
__cpp_lib_is_constant_evaluated 201811L <type_traits>
140140
__cpp_lib_is_final 201402L <type_traits>
141+
__cpp_lib_is_implicit_lifetime 202302L <type_traits>
141142
__cpp_lib_is_invocable 201703L <type_traits>
142143
__cpp_lib_is_layout_compatible 201907L <type_traits>
143144
__cpp_lib_is_nothrow_convertible 201806L <type_traits>
@@ -473,6 +474,9 @@ __cpp_lib_void_t 201411L <type_traits>
473474
# define __cpp_lib_forward_like 202207L
474475
# define __cpp_lib_invoke_r 202106L
475476
# define __cpp_lib_ios_noreplace 202207L
477+
# if __has_builtin(__builtin_is_implicit_lifetime)
478+
# define __cpp_lib_is_implicit_lifetime 202302L
479+
# endif
476480
# define __cpp_lib_is_scoped_enum 202011L
477481
# define __cpp_lib_mdspan 202207L
478482
# define __cpp_lib_modules 202207L

libcxx/modules/std/type_traits.inc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ export namespace std {
9898

9999
using std::is_nothrow_destructible;
100100

101-
// using std::is_implicit_lifetime;
101+
#if _LIBCPP_STD_VER >= 23 && __has_builtin(__builtin_is_implicit_lifetime)
102+
using std::is_implicit_lifetime;
103+
#endif
102104

103105
using std::has_virtual_destructor;
104106

@@ -243,7 +245,9 @@ export namespace std {
243245
using std::is_destructible_v;
244246
using std::is_empty_v;
245247
using std::is_final_v;
246-
// using std::is_implicit_lifetime_v;
248+
#if _LIBCPP_STD_VER >= 23 && __has_builtin(__builtin_is_implicit_lifetime)
249+
using std::is_implicit_lifetime_v;
250+
#endif
247251
using std::is_move_assignable_v;
248252
using std::is_move_constructible_v;
249253
using std::is_nothrow_assignable_v;

libcxx/test/std/language.support/support.limits/support.limits.general/type_traits.version.compile.pass.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
__cpp_lib_is_aggregate 201703L [C++17]
2424
__cpp_lib_is_constant_evaluated 201811L [C++20]
2525
__cpp_lib_is_final 201402L [C++14]
26+
__cpp_lib_is_implicit_lifetime 202302L [C++23]
2627
__cpp_lib_is_invocable 201703L [C++17]
2728
__cpp_lib_is_layout_compatible 201907L [C++20]
2829
__cpp_lib_is_nothrow_convertible 201806L [C++20]
@@ -75,6 +76,10 @@
7576
# error "__cpp_lib_is_final should not be defined before c++14"
7677
# endif
7778

79+
# ifdef __cpp_lib_is_implicit_lifetime
80+
# error "__cpp_lib_is_implicit_lifetime should not be defined before c++23"
81+
# endif
82+
7883
# ifdef __cpp_lib_is_invocable
7984
# error "__cpp_lib_is_invocable should not be defined before c++17"
8085
# endif
@@ -179,6 +184,10 @@
179184
# error "__cpp_lib_is_final should have the value 201402L in c++14"
180185
# endif
181186

187+
# ifdef __cpp_lib_is_implicit_lifetime
188+
# error "__cpp_lib_is_implicit_lifetime should not be defined before c++23"
189+
# endif
190+
182191
# ifdef __cpp_lib_is_invocable
183192
# error "__cpp_lib_is_invocable should not be defined before c++17"
184193
# endif
@@ -301,6 +310,10 @@
301310
# error "__cpp_lib_is_final should have the value 201402L in c++17"
302311
# endif
303312

313+
# ifdef __cpp_lib_is_implicit_lifetime
314+
# error "__cpp_lib_is_implicit_lifetime should not be defined before c++23"
315+
# endif
316+
304317
# ifndef __cpp_lib_is_invocable
305318
# error "__cpp_lib_is_invocable should be defined in c++17"
306319
# endif
@@ -444,6 +457,10 @@
444457
# error "__cpp_lib_is_final should have the value 201402L in c++20"
445458
# endif
446459

460+
# ifdef __cpp_lib_is_implicit_lifetime
461+
# error "__cpp_lib_is_implicit_lifetime should not be defined before c++23"
462+
# endif
463+
447464
# ifndef __cpp_lib_is_invocable
448465
# error "__cpp_lib_is_invocable should be defined in c++20"
449466
# endif
@@ -614,6 +631,19 @@
614631
# error "__cpp_lib_is_final should have the value 201402L in c++23"
615632
# endif
616633

634+
# if __has_builtin(__builtin_is_implicit_lifetime)
635+
# ifndef __cpp_lib_is_implicit_lifetime
636+
# error "__cpp_lib_is_implicit_lifetime should be defined in c++23"
637+
# endif
638+
# if __cpp_lib_is_implicit_lifetime != 202302L
639+
# error "__cpp_lib_is_implicit_lifetime should have the value 202302L in c++23"
640+
# endif
641+
# else
642+
# ifdef __cpp_lib_is_implicit_lifetime
643+
# error "__cpp_lib_is_implicit_lifetime should not be defined when the requirement '__has_builtin(__builtin_is_implicit_lifetime)' is not met!"
644+
# endif
645+
# endif
646+
617647
# ifndef __cpp_lib_is_invocable
618648
# error "__cpp_lib_is_invocable should be defined in c++23"
619649
# endif
@@ -796,6 +826,19 @@
796826
# error "__cpp_lib_is_final should have the value 201402L in c++26"
797827
# endif
798828

829+
# if __has_builtin(__builtin_is_implicit_lifetime)
830+
# ifndef __cpp_lib_is_implicit_lifetime
831+
# error "__cpp_lib_is_implicit_lifetime should be defined in c++26"
832+
# endif
833+
# if __cpp_lib_is_implicit_lifetime != 202302L
834+
# error "__cpp_lib_is_implicit_lifetime should have the value 202302L in c++26"
835+
# endif
836+
# else
837+
# ifdef __cpp_lib_is_implicit_lifetime
838+
# error "__cpp_lib_is_implicit_lifetime should not be defined when the requirement '__has_builtin(__builtin_is_implicit_lifetime)' is not met!"
839+
# endif
840+
# endif
841+
799842
# ifndef __cpp_lib_is_invocable
800843
# error "__cpp_lib_is_invocable should be defined in c++26"
801844
# endif

libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
__cpp_lib_is_aggregate 201703L [C++17]
126126
__cpp_lib_is_constant_evaluated 201811L [C++20]
127127
__cpp_lib_is_final 201402L [C++14]
128+
__cpp_lib_is_implicit_lifetime 202302L [C++23]
128129
__cpp_lib_is_invocable 201703L [C++17]
129130
__cpp_lib_is_layout_compatible 201907L [C++20]
130131
__cpp_lib_is_nothrow_convertible 201806L [C++20]
@@ -671,6 +672,10 @@
671672
# error "__cpp_lib_is_final should not be defined before c++14"
672673
# endif
673674

675+
# ifdef __cpp_lib_is_implicit_lifetime
676+
# error "__cpp_lib_is_implicit_lifetime should not be defined before c++23"
677+
# endif
678+
674679
# ifdef __cpp_lib_is_invocable
675680
# error "__cpp_lib_is_invocable should not be defined before c++17"
676681
# endif
@@ -1550,6 +1555,10 @@
15501555
# error "__cpp_lib_is_final should have the value 201402L in c++14"
15511556
# endif
15521557

1558+
# ifdef __cpp_lib_is_implicit_lifetime
1559+
# error "__cpp_lib_is_implicit_lifetime should not be defined before c++23"
1560+
# endif
1561+
15531562
# ifdef __cpp_lib_is_invocable
15541563
# error "__cpp_lib_is_invocable should not be defined before c++17"
15551564
# endif
@@ -2564,6 +2573,10 @@
25642573
# error "__cpp_lib_is_final should have the value 201402L in c++17"
25652574
# endif
25662575

2576+
# ifdef __cpp_lib_is_implicit_lifetime
2577+
# error "__cpp_lib_is_implicit_lifetime should not be defined before c++23"
2578+
# endif
2579+
25672580
# ifndef __cpp_lib_is_invocable
25682581
# error "__cpp_lib_is_invocable should be defined in c++17"
25692582
# endif
@@ -3842,6 +3855,10 @@
38423855
# error "__cpp_lib_is_final should have the value 201402L in c++20"
38433856
# endif
38443857

3858+
# ifdef __cpp_lib_is_implicit_lifetime
3859+
# error "__cpp_lib_is_implicit_lifetime should not be defined before c++23"
3860+
# endif
3861+
38453862
# ifndef __cpp_lib_is_invocable
38463863
# error "__cpp_lib_is_invocable should be defined in c++20"
38473864
# endif
@@ -5306,6 +5323,19 @@
53065323
# error "__cpp_lib_is_final should have the value 201402L in c++23"
53075324
# endif
53085325

5326+
# if __has_builtin(__builtin_is_implicit_lifetime)
5327+
# ifndef __cpp_lib_is_implicit_lifetime
5328+
# error "__cpp_lib_is_implicit_lifetime should be defined in c++23"
5329+
# endif
5330+
# if __cpp_lib_is_implicit_lifetime != 202302L
5331+
# error "__cpp_lib_is_implicit_lifetime should have the value 202302L in c++23"
5332+
# endif
5333+
# else
5334+
# ifdef __cpp_lib_is_implicit_lifetime
5335+
# error "__cpp_lib_is_implicit_lifetime should not be defined when the requirement '__has_builtin(__builtin_is_implicit_lifetime)' is not met!"
5336+
# endif
5337+
# endif
5338+
53095339
# ifndef __cpp_lib_is_invocable
53105340
# error "__cpp_lib_is_invocable should be defined in c++23"
53115341
# endif
@@ -7112,6 +7142,19 @@
71127142
# error "__cpp_lib_is_final should have the value 201402L in c++26"
71137143
# endif
71147144

7145+
# if __has_builtin(__builtin_is_implicit_lifetime)
7146+
# ifndef __cpp_lib_is_implicit_lifetime
7147+
# error "__cpp_lib_is_implicit_lifetime should be defined in c++26"
7148+
# endif
7149+
# if __cpp_lib_is_implicit_lifetime != 202302L
7150+
# error "__cpp_lib_is_implicit_lifetime should have the value 202302L in c++26"
7151+
# endif
7152+
# else
7153+
# ifdef __cpp_lib_is_implicit_lifetime
7154+
# error "__cpp_lib_is_implicit_lifetime should not be defined when the requirement '__has_builtin(__builtin_is_implicit_lifetime)' is not met!"
7155+
# endif
7156+
# endif
7157+
71157158
# ifndef __cpp_lib_is_invocable
71167159
# error "__cpp_lib_is_invocable should be defined in c++26"
71177160
# endif

libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp

Lines changed: 4 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
1010

11+
// These compilers don't support __builtin_is_implicit_lifetime yet.
12+
// UNSUPPORTED: clang-17, clang-18, clang-19, gcc-14, apple-clang-16, apple-clang-17
13+
1114
// <type_traits>
1215

1316
// template<class T> struct is_implicit_lifetime;
@@ -106,10 +109,8 @@ struct StructWithZeroSizedArray {
106109
};
107110

108111
#ifdef TEST_COMPILER_CLANG
109-
// typedef int *align_value_int __attribute__((align_value(16)));
110112
using AlignValueInt = int* __attribute__((align_value(16)));
111-
// typedef float float4 __attribute__((ext_vector_type(4)));
112-
using Float4 = float __attribute__((ext_vector_type(4)));
113+
using Float4 = float __attribute__((ext_vector_type(4)));
113114

114115
struct [[clang::enforce_read_only_placement]] EnforceReadOnlyPlacement {};
115116
struct [[clang::type_visibility("hidden")]] TypeVisibility {};
@@ -146,22 +147,6 @@ constexpr void test_is_implicit_lifetime() {
146147
test_is_implicit_lifetime<T[94], true>();
147148
}
148149

149-
// #ifdef TEST_COMPILER_CLANG
150-
// // Test language extensions: attributes
151-
// template <typename T>
152-
// constexpr void test_is_implicit_lifetime_with_attributes() {
153-
// test_is_implicit_lifetime<T [[clang::annotate_type("category2")]]*, true>();
154-
// test_is_implicit_lifetime<T __attribute__((btf_type_tag("user")))*, true>();
155-
// static_assert(__builtin_is_implicit_lifetime(int __attribute__((btf_type_tag("user"))) *));
156-
157-
// test_is_implicit_lifetime<T __attribute__((noderef))*, true>();
158-
159-
// test_is_implicit_lifetime<T* _Nonnull, true>();
160-
// test_is_implicit_lifetime<T* _Null_unspecified, true>();
161-
// test_is_implicit_lifetime<T* _Nullable, true>();
162-
// }
163-
// #endif // TEST_COMPILER_CLANG
164-
165150
constexpr bool test() {
166151
// Standard fundamental C++ types
167152

@@ -188,14 +173,6 @@ constexpr bool test() {
188173
test_is_implicit_lifetime<char16_t>();
189174
test_is_implicit_lifetime<char32_t>();
190175

191-
// test_is_implicit_lifetime<int, true>();
192-
// test_is_implicit_lifetime<int&, false>();
193-
// test_is_implicit_lifetime<int&&, false>();
194-
195-
// test_is_implicit_lifetime<int*, true>();
196-
// test_is_implicit_lifetime<int[], true>();
197-
// test_is_implicit_lifetime<int[0], true>();
198-
// test_is_implicit_lifetime<int[94], true>();
199176
test_is_implicit_lifetime<short>();
200177
test_is_implicit_lifetime<short int>();
201178
test_is_implicit_lifetime<signed short>();
@@ -238,12 +215,6 @@ constexpr bool test() {
238215
test_is_implicit_lifetime<void (&)(), false>();
239216
test_is_implicit_lifetime<void (*)(), true>();
240217

241-
// test_is_implicit_lifetime<int UserDeclaredDestructor::*, true>();
242-
// test_is_implicit_lifetime<int (UserDeclaredDestructor::*)(), true>();
243-
// test_is_implicit_lifetime<int (UserDeclaredDestructor::*)() const, true>();
244-
// test_is_implicit_lifetime<int (UserDeclaredDestructor::*)()&, true>();
245-
// test_is_implicit_lifetime<int (UserDeclaredDestructor::*)()&&, true>();
246-
247218
// Implicit-lifetime class types
248219

249220
test_is_implicit_lifetime<EmptyStruct>();
@@ -301,10 +272,6 @@ constexpr bool test() {
301272
test_is_implicit_lifetime<_Complex double>();
302273
test_is_implicit_lifetime<_Complex long double>();
303274

304-
// test_is_implicit_lifetime<_Imaginary float>();
305-
// test_is_implicit_lifetime<_Imaginary double>();
306-
// test_is_implicit_lifetime<_Imaginary long double>();
307-
308275
// Standard C23 types
309276

310277
#ifdef TEST_COMPILER_CLANG
@@ -319,9 +286,6 @@ constexpr bool test() {
319286
test_is_implicit_lifetime<__uint128_t>();
320287
#endif
321288

322-
// #if __STDC_VERSION__ >= 20
323-
// #endif
324-
325289
#ifdef TEST_COMPILER_CLANG
326290
// https://clang.llvm.org/docs/LanguageExtensions.html#half-precision-floating-point
327291
test_is_implicit_lifetime<__fp16>();
@@ -337,9 +301,6 @@ constexpr bool test() {
337301
test_is_implicit_lifetime<EnforceReadOnlyPlacement, true>();
338302
test_is_implicit_lifetime<TypeVisibility, true>();
339303

340-
// test_is_implicit_lifetime_with_attributes<int>();
341-
// test_is_implicit_lifetime_with_attributes<float>();
342-
343304
test_is_implicit_lifetime<int [[clang::annotate_type("category2")]]*, true>();
344305
test_is_implicit_lifetime<int __attribute__((btf_type_tag("user")))*, true>();
345306

0 commit comments

Comments
 (0)