[libcxx-commits] [libcxx] [libc++] Use [[clang::no_specializations]] to diagnose invalid user specializations (PR #118167)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Nov 30 03:13:42 PST 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff d648eed5899c4be10f1f7866eebef2bc171e673f 427a291ddd1ee162b856d7b23842c24d35b6796f --extensions ,cpp,h -- libcxx/test/libcxx/algorithms/no_specializations.verify.cpp libcxx/test/libcxx/language.support/no_specializations.verify.cpp libcxx/test/libcxx/ranges/no_specializations.verify.cpp libcxx/test/libcxx/type_traits/no_specializations.verify.cpp libcxx/test/libcxx/utilities/format/no_specializations.verify.cpp libcxx/test/libcxx/utilities/no_specializations.verify.cpp libcxx/include/__compare/compare_three_way_result.h libcxx/include/__config libcxx/include/__cxx03/__type_traits/add_const.h libcxx/include/__cxx03/__type_traits/add_cv.h libcxx/include/__cxx03/__type_traits/add_volatile.h libcxx/include/__format/format_arg.h libcxx/include/__ranges/range_adaptor.h libcxx/include/__type_traits/add_cv_quals.h libcxx/include/__type_traits/add_lvalue_reference.h libcxx/include/__type_traits/add_pointer.h libcxx/include/__type_traits/add_rvalue_reference.h libcxx/include/__type_traits/aligned_storage.h libcxx/include/__type_traits/aligned_union.h libcxx/include/__type_traits/alignment_of.h libcxx/include/__type_traits/conjunction.h libcxx/include/__type_traits/decay.h libcxx/include/__type_traits/disjunction.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_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_convertible.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_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/make_signed.h libcxx/include/__type_traits/make_unsigned.h libcxx/include/__type_traits/negation.h libcxx/include/__type_traits/remove_all_extents.h libcxx/include/__type_traits/remove_const.h libcxx/include/__type_traits/remove_cv.h libcxx/include/__type_traits/remove_cvref.h libcxx/include/__type_traits/remove_extent.h libcxx/include/__type_traits/remove_pointer.h libcxx/include/__type_traits/remove_reference.h libcxx/include/__type_traits/remove_volatile.h libcxx/include/__type_traits/type_identity.h libcxx/include/__type_traits/underlying_type.h libcxx/include/__type_traits/unwrap_ref.h libcxx/include/variant
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/libcxx/include/__type_traits/extent.h b/libcxx/include/__type_traits/extent.h
index 77e59193d3..6f3db916f9 100644
--- a/libcxx/include/__type_traits/extent.h
+++ b/libcxx/include/__type_traits/extent.h
@@ -22,8 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#if __has_builtin(__array_extent)
template <class _Tp, size_t _Dim = 0>
-struct _LIBCPP_NO_SPECIALIZATIONS _LIBCPP_TEMPLATE_VIS extent
- : integral_constant<size_t, __array_extent(_Tp, _Dim)> {};
+struct _LIBCPP_NO_SPECIALIZATIONS _LIBCPP_TEMPLATE_VIS extent : integral_constant<size_t, __array_extent(_Tp, _Dim)> {};
# if _LIBCPP_STD_VER >= 17
template <class _Tp, unsigned _Ip = 0>
diff --git a/libcxx/include/__type_traits/invoke.h b/libcxx/include/__type_traits/invoke.h
index aa3b7cd2fe..c386355ea0 100644
--- a/libcxx/include/__type_traits/invoke.h
+++ b/libcxx/include/__type_traits/invoke.h
@@ -254,8 +254,7 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_invocable_r
: integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {};
template <class _Fn, class... _Args>
-_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_invocable_v =
- is_nothrow_invocable<_Fn, _Args...>::value;
+_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_invocable_v = is_nothrow_invocable<_Fn, _Args...>::value;
template <class _Ret, class _Fn, class... _Args>
_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_invocable_r_v =
diff --git a/libcxx/include/__type_traits/is_assignable.h b/libcxx/include/__type_traits/is_assignable.h
index 926ef3f4a4..2a87bcc673 100644
--- a/libcxx/include/__type_traits/is_assignable.h
+++ b/libcxx/include/__type_traits/is_assignable.h
@@ -21,8 +21,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp, class _Up>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> {
-};
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> {};
#if _LIBCPP_STD_VER >= 17
template <class _Tp, class _Arg>
diff --git a/libcxx/include/__type_traits/is_base_of.h b/libcxx/include/__type_traits/is_base_of.h
index e1958eff5f..a48b8caded 100644
--- a/libcxx/include/__type_traits/is_base_of.h
+++ b/libcxx/include/__type_traits/is_base_of.h
@@ -35,8 +35,7 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_virtual_base_of
: public bool_constant<__builtin_is_virtual_base_of(_Base, _Derived)> {};
template <class _Base, class _Derived>
-_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_virtual_base_of_v =
- __builtin_is_virtual_base_of(_Base, _Derived);
+_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_virtual_base_of_v = __builtin_is_virtual_base_of(_Base, _Derived);
# endif
#endif
diff --git a/libcxx/include/__type_traits/is_class.h b/libcxx/include/__type_traits/is_class.h
index 6cff58a479..5fce840058 100644
--- a/libcxx/include/__type_traits/is_class.h
+++ b/libcxx/include/__type_traits/is_class.h
@@ -19,8 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_class
- : public integral_constant<bool, __is_class(_Tp)> {};
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_class : public integral_constant<bool, __is_class(_Tp)> {};
#if _LIBCPP_STD_VER >= 17
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_empty.h b/libcxx/include/__type_traits/is_empty.h
index 6056b1ae83..8e66cd97a9 100644
--- a/libcxx/include/__type_traits/is_empty.h
+++ b/libcxx/include/__type_traits/is_empty.h
@@ -19,8 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_empty
- : public integral_constant<bool, __is_empty(_Tp)> {};
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_empty : public integral_constant<bool, __is_empty(_Tp)> {};
#if _LIBCPP_STD_VER >= 17
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_enum.h b/libcxx/include/__type_traits/is_enum.h
index c6496f8644..bc210ea289 100644
--- a/libcxx/include/__type_traits/is_enum.h
+++ b/libcxx/include/__type_traits/is_enum.h
@@ -19,8 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_enum : public integral_constant<bool, __is_enum(_Tp)> {
-};
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_enum : public integral_constant<bool, __is_enum(_Tp)> {};
#if _LIBCPP_STD_VER >= 17
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_final.h b/libcxx/include/__type_traits/is_final.h
index bdda264ed1..19d3ac3ecd 100644
--- a/libcxx/include/__type_traits/is_final.h
+++ b/libcxx/include/__type_traits/is_final.h
@@ -23,8 +23,7 @@ struct _LIBCPP_TEMPLATE_VIS __libcpp_is_final : public integral_constant<bool, _
#if _LIBCPP_STD_VER >= 14
template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_final
- : public integral_constant<bool, __is_final(_Tp)> {};
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_final : public integral_constant<bool, __is_final(_Tp)> {};
#endif
#if _LIBCPP_STD_VER >= 17
diff --git a/libcxx/include/__type_traits/is_function.h b/libcxx/include/__type_traits/is_function.h
index 2dbb3be8c1..63b842b26c 100644
--- a/libcxx/include/__type_traits/is_function.h
+++ b/libcxx/include/__type_traits/is_function.h
@@ -19,8 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_function : integral_constant<bool, __is_function(_Tp)> {
-};
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_function : integral_constant<bool, __is_function(_Tp)> {};
#if _LIBCPP_STD_VER >= 17
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_literal_type.h b/libcxx/include/__type_traits/is_literal_type.h
index 9381cfb103..e78343ee2f 100644
--- a/libcxx/include/__type_traits/is_literal_type.h
+++ b/libcxx/include/__type_traits/is_literal_type.h
@@ -25,8 +25,7 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_NO_SPECIALIZATIO
# if _LIBCPP_STD_VER >= 17
template <class _Tp>
-_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_literal_type_v =
- __is_literal_type(_Tp);
+_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_literal_type_v = __is_literal_type(_Tp);
# endif // _LIBCPP_STD_VER >= 17
#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
diff --git a/libcxx/include/__type_traits/is_member_pointer.h b/libcxx/include/__type_traits/is_member_pointer.h
index b822620440..8a4f1fe0c7 100644
--- a/libcxx/include/__type_traits/is_member_pointer.h
+++ b/libcxx/include/__type_traits/is_member_pointer.h
@@ -19,8 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_member_pointer
- : _BoolConstant<__is_member_pointer(_Tp)> {};
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> {};
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_member_object_pointer
diff --git a/libcxx/include/__type_traits/is_nothrow_assignable.h b/libcxx/include/__type_traits/is_nothrow_assignable.h
index ba67c8a05b..4727deb6c3 100644
--- a/libcxx/include/__type_traits/is_nothrow_assignable.h
+++ b/libcxx/include/__type_traits/is_nothrow_assignable.h
@@ -37,8 +37,7 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_copy_assignabl
#if _LIBCPP_STD_VER >= 17
template <class _Tp>
-_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_copy_assignable_v =
- is_nothrow_copy_assignable<_Tp>::value;
+_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<_Tp>::value;
#endif
template <class _Tp>
@@ -49,8 +48,7 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_move_assignabl
#if _LIBCPP_STD_VER >= 17
template <class _Tp>
-_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_move_assignable_v =
- is_nothrow_move_assignable<_Tp>::value;
+_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<_Tp>::value;
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_nothrow_constructible.h b/libcxx/include/__type_traits/is_nothrow_constructible.h
index 28f2ffde12..1e4eebd006 100644
--- a/libcxx/include/__type_traits/is_nothrow_constructible.h
+++ b/libcxx/include/__type_traits/is_nothrow_constructible.h
@@ -56,8 +56,7 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_default_constr
#if _LIBCPP_STD_VER >= 17
template <class _Tp>
-_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_default_constructible_v =
- __is_nothrow_constructible(_Tp);
+_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_default_constructible_v = __is_nothrow_constructible(_Tp);
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_reference.h b/libcxx/include/__type_traits/is_reference.h
index 65d7de6a2e..564e888b77 100644
--- a/libcxx/include/__type_traits/is_reference.h
+++ b/libcxx/include/__type_traits/is_reference.h
@@ -29,12 +29,12 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_reference_v = __is_reference
#if __has_builtin(__is_lvalue_reference) && __has_builtin(__is_rvalue_reference)
template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_lvalue_reference
- : _BoolConstant<__is_lvalue_reference(_Tp)> {};
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> {
+};
template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_rvalue_reference
- : _BoolConstant<__is_rvalue_reference(_Tp)> {};
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> {
+};
# if _LIBCPP_STD_VER >= 17
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_swappable.h b/libcxx/include/__type_traits/is_swappable.h
index 6ac2c4a1a9..a659262c8d 100644
--- a/libcxx/include/__type_traits/is_swappable.h
+++ b/libcxx/include/__type_traits/is_swappable.h
@@ -87,8 +87,7 @@ template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_swappable : bool_constant<is_swappable_v<_Tp>> {};
template <class _Tp, class _Up>
-_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_swappable_with_v =
- __is_nothrow_swappable_with_v<_Tp, _Up>;
+_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_swappable_with_v = __is_nothrow_swappable_with_v<_Tp, _Up>;
template <class _Tp, class _Up>
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_swappable_with
diff --git a/libcxx/include/__type_traits/is_trivial.h b/libcxx/include/__type_traits/is_trivial.h
index a2863329a5..a4ca2d6b26 100644
--- a/libcxx/include/__type_traits/is_trivial.h
+++ b/libcxx/include/__type_traits/is_trivial.h
@@ -19,8 +19,8 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivial
- : public integral_constant<bool, __is_trivial(_Tp)> {};
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivial : public integral_constant<bool, __is_trivial(_Tp)> {
+};
#if _LIBCPP_STD_VER >= 17
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_trivially_destructible.h b/libcxx/include/__type_traits/is_trivially_destructible.h
index c85cf0f10a..3bca575528 100644
--- a/libcxx/include/__type_traits/is_trivially_destructible.h
+++ b/libcxx/include/__type_traits/is_trivially_destructible.h
@@ -39,8 +39,7 @@ struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible
#if _LIBCPP_STD_VER >= 17
template <class _Tp>
-_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_destructible_v =
- is_trivially_destructible<_Tp>::value;
+_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_destructible_v = is_trivially_destructible<_Tp>::value;
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__type_traits/is_union.h b/libcxx/include/__type_traits/is_union.h
index d1a7f1e35d..4be5ae0118 100644
--- a/libcxx/include/__type_traits/is_union.h
+++ b/libcxx/include/__type_traits/is_union.h
@@ -19,8 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_union
- : public integral_constant<bool, __is_union(_Tp)> {};
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_union : public integral_constant<bool, __is_union(_Tp)> {};
#if _LIBCPP_STD_VER >= 17
template <class _Tp>
diff --git a/libcxx/include/__type_traits/is_void.h b/libcxx/include/__type_traits/is_void.h
index 0e2c276ab7..48d73ce49a 100644
--- a/libcxx/include/__type_traits/is_void.h
+++ b/libcxx/include/__type_traits/is_void.h
@@ -19,8 +19,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Tp>
-struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_void
- : _BoolConstant<__is_same(__remove_cv(_Tp), void)> {};
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_void : _BoolConstant<__is_same(__remove_cv(_Tp), void)> {};
#if _LIBCPP_STD_VER >= 17
template <class _Tp>
``````````
</details>
https://github.com/llvm/llvm-project/pull/118167
More information about the libcxx-commits
mailing list