mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 18:16:42 +00:00
[libc++] Add [[gnu::nodebug]] on type traits (#128502)
This commit is contained in:
parent
4781a8ebd0
commit
fb44f00641
@ -191,6 +191,7 @@ Library-internal type aliases should be annotated with ``_LIBCPP_NODEBUG``
|
||||
Libc++ has lots of internal type aliases. Accumulated, these can result in significant amounts of debug information that
|
||||
users generally don't care about, since users don't try to debug standard library facilities in most cases. For that
|
||||
reason, all library-internal type aliases that aren't function-local should be annotated with ``_LIBCPP_NODEBUG`` to
|
||||
prevent compilers from generating said debug information.
|
||||
prevent compilers from generating said debug information. Aliases inside type traits (i.e. aliases named ``type``)
|
||||
should be annotated for the same reason.
|
||||
|
||||
This is enforced by the clang-tidy check ``libcpp-nodebug-on-aliases``.
|
||||
|
@ -51,20 +51,20 @@ struct __get_as_integer_type_impl;
|
||||
|
||||
template <>
|
||||
struct __get_as_integer_type_impl<1> {
|
||||
using type = uint8_t;
|
||||
using type _LIBCPP_NODEBUG = uint8_t;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct __get_as_integer_type_impl<2> {
|
||||
using type = uint16_t;
|
||||
using type _LIBCPP_NODEBUG = uint16_t;
|
||||
};
|
||||
template <>
|
||||
struct __get_as_integer_type_impl<4> {
|
||||
using type = uint32_t;
|
||||
using type _LIBCPP_NODEBUG = uint32_t;
|
||||
};
|
||||
template <>
|
||||
struct __get_as_integer_type_impl<8> {
|
||||
using type = uint64_t;
|
||||
using type _LIBCPP_NODEBUG = uint64_t;
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
|
@ -73,7 +73,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 {
|
||||
using type = decltype(__comp_detail::__get_comp_type<_Ts...>());
|
||||
using type _LIBCPP_NODEBUG = decltype(__comp_detail::__get_comp_type<_Ts...>());
|
||||
};
|
||||
|
||||
template <class... _Ts>
|
||||
|
@ -29,7 +29,8 @@ struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result<
|
||||
_Tp,
|
||||
_Up,
|
||||
decltype(std::declval<__make_const_lvalue_ref<_Tp>>() <=> std::declval<__make_const_lvalue_ref<_Up>>(), void())> {
|
||||
using type = decltype(std::declval<__make_const_lvalue_ref<_Tp>>() <=> std::declval<__make_const_lvalue_ref<_Up>>());
|
||||
using type _LIBCPP_NODEBUG =
|
||||
decltype(std::declval<__make_const_lvalue_ref<_Tp>>() <=> std::declval<__make_const_lvalue_ref<_Up>>());
|
||||
};
|
||||
|
||||
template <class _Tp, class _Up = _Tp>
|
||||
|
@ -130,7 +130,7 @@ struct __mu_return_invokable // false
|
||||
|
||||
template <class _Ti, class... _Uj>
|
||||
struct __mu_return_invokable<true, _Ti, _Uj...> {
|
||||
using type = __invoke_result_t<_Ti&, _Uj...>;
|
||||
using type _LIBCPP_NODEBUG = __invoke_result_t<_Ti&, _Uj...>;
|
||||
};
|
||||
|
||||
template <class _Ti, class... _Uj>
|
||||
@ -181,12 +181,12 @@ struct __bind_return;
|
||||
|
||||
template <class _Fp, class... _BoundArgs, class _TupleUj>
|
||||
struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true> {
|
||||
using type = __invoke_result_t< _Fp&, typename __mu_return< _BoundArgs, _TupleUj >::type... >;
|
||||
using type _LIBCPP_NODEBUG = __invoke_result_t<_Fp&, typename __mu_return<_BoundArgs, _TupleUj>::type...>;
|
||||
};
|
||||
|
||||
template <class _Fp, class... _BoundArgs, class _TupleUj>
|
||||
struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> {
|
||||
using type = __invoke_result_t< _Fp&, typename __mu_return< const _BoundArgs, _TupleUj >::type... >;
|
||||
using type _LIBCPP_NODEBUG = __invoke_result_t<_Fp&, typename __mu_return<const _BoundArgs, _TupleUj>::type...>;
|
||||
};
|
||||
|
||||
template <class _Fp, class _BoundArgs, size_t... _Indx, class _Args>
|
||||
|
@ -272,13 +272,13 @@ concept __common_iter_has_ptr_op = requires(const common_iterator<_Iter, _Sent>&
|
||||
|
||||
template <class, class>
|
||||
struct __arrow_type_or_void {
|
||||
using type = void;
|
||||
using type _LIBCPP_NODEBUG = void;
|
||||
};
|
||||
|
||||
template <class _Iter, class _Sent>
|
||||
requires __common_iter_has_ptr_op<_Iter, _Sent>
|
||||
struct __arrow_type_or_void<_Iter, _Sent> {
|
||||
using type = decltype(std::declval<const common_iterator<_Iter, _Sent>&>().operator->());
|
||||
using type _LIBCPP_NODEBUG = decltype(std::declval<const common_iterator<_Iter, _Sent>&>().operator->());
|
||||
};
|
||||
|
||||
template <input_iterator _Iter, class _Sent>
|
||||
|
@ -80,12 +80,13 @@ concept __specialization_of_projected = requires {
|
||||
|
||||
template <class _Tp>
|
||||
struct __indirect_value_t_impl {
|
||||
using type = iter_value_t<_Tp>&;
|
||||
using type _LIBCPP_NODEBUG = iter_value_t<_Tp>&;
|
||||
};
|
||||
template <__specialization_of_projected _Tp>
|
||||
struct __indirect_value_t_impl<_Tp> {
|
||||
using type = invoke_result_t<__projected_projection_t<_Tp>&,
|
||||
typename __indirect_value_t_impl<__projected_iterator_t<_Tp>>::type>;
|
||||
using type _LIBCPP_NODEBUG =
|
||||
invoke_result_t<__projected_projection_t<_Tp>&,
|
||||
typename __indirect_value_t_impl<__projected_iterator_t<_Tp>>::type>;
|
||||
};
|
||||
|
||||
template <indirectly_readable _Tp>
|
||||
|
@ -77,7 +77,8 @@ struct _LIBCPP_TEMPLATE_VIS contiguous_iterator_tag : public random_access_itera
|
||||
|
||||
template <class _Iter>
|
||||
struct __iter_traits_cache {
|
||||
using type = _If< __is_primary_template<iterator_traits<_Iter> >::value, _Iter, iterator_traits<_Iter> >;
|
||||
using type _LIBCPP_NODEBUG =
|
||||
_If<__is_primary_template<iterator_traits<_Iter> >::value, _Iter, iterator_traits<_Iter> >;
|
||||
};
|
||||
template <class _Iter>
|
||||
using _ITER_TRAITS _LIBCPP_NODEBUG = typename __iter_traits_cache<_Iter>::type;
|
||||
@ -101,9 +102,10 @@ struct __test_iter_concept : _IsValidExpansion<_Tester::template _Apply, _Iter>,
|
||||
|
||||
template <class _Iter>
|
||||
struct __iter_concept_cache {
|
||||
using type = _Or< __test_iter_concept<_Iter, __iter_concept_concept_test>,
|
||||
__test_iter_concept<_Iter, __iter_concept_category_test>,
|
||||
__test_iter_concept<_Iter, __iter_concept_random_fallback> >;
|
||||
using type _LIBCPP_NODEBUG =
|
||||
_Or<__test_iter_concept<_Iter, __iter_concept_concept_test>,
|
||||
__test_iter_concept<_Iter, __iter_concept_category_test>,
|
||||
__test_iter_concept<_Iter, __iter_concept_random_fallback> >;
|
||||
};
|
||||
|
||||
template <class _Iter>
|
||||
@ -221,12 +223,12 @@ concept __specifies_members = requires {
|
||||
|
||||
template <class>
|
||||
struct __iterator_traits_member_pointer_or_void {
|
||||
using type = void;
|
||||
using type _LIBCPP_NODEBUG = void;
|
||||
};
|
||||
|
||||
template <__has_member_pointer _Tp>
|
||||
struct __iterator_traits_member_pointer_or_void<_Tp> {
|
||||
using type = typename _Tp::pointer;
|
||||
using type _LIBCPP_NODEBUG = typename _Tp::pointer;
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
@ -239,14 +241,14 @@ concept __cpp17_input_iterator_missing_members =
|
||||
// Otherwise, `pointer` names `void`.
|
||||
template <class>
|
||||
struct __iterator_traits_member_pointer_or_arrow_or_void {
|
||||
using type = void;
|
||||
using type _LIBCPP_NODEBUG = void;
|
||||
};
|
||||
|
||||
// [iterator.traits]/3.2.1
|
||||
// If the qualified-id `I::pointer` is valid and denotes a type, `pointer` names that type.
|
||||
template <__has_member_pointer _Ip>
|
||||
struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> {
|
||||
using type = typename _Ip::pointer;
|
||||
using type _LIBCPP_NODEBUG = typename _Ip::pointer;
|
||||
};
|
||||
|
||||
// Otherwise, if `decltype(declval<I&>().operator->())` is well-formed, then `pointer` names that
|
||||
@ -254,48 +256,48 @@ struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> {
|
||||
template <class _Ip>
|
||||
requires requires(_Ip& __i) { __i.operator->(); } && (!__has_member_pointer<_Ip>)
|
||||
struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> {
|
||||
using type = decltype(std::declval<_Ip&>().operator->());
|
||||
using type _LIBCPP_NODEBUG = decltype(std::declval<_Ip&>().operator->());
|
||||
};
|
||||
|
||||
// Otherwise, `reference` names `iter-reference-t<I>`.
|
||||
template <class _Ip>
|
||||
struct __iterator_traits_member_reference {
|
||||
using type = iter_reference_t<_Ip>;
|
||||
using type _LIBCPP_NODEBUG = iter_reference_t<_Ip>;
|
||||
};
|
||||
|
||||
// [iterator.traits]/3.2.2
|
||||
// If the qualified-id `I::reference` is valid and denotes a type, `reference` names that type.
|
||||
template <__has_member_reference _Ip>
|
||||
struct __iterator_traits_member_reference<_Ip> {
|
||||
using type = typename _Ip::reference;
|
||||
using type _LIBCPP_NODEBUG = typename _Ip::reference;
|
||||
};
|
||||
|
||||
// [iterator.traits]/3.2.3.4
|
||||
// input_iterator_tag
|
||||
template <class _Ip>
|
||||
struct __deduce_iterator_category {
|
||||
using type = input_iterator_tag;
|
||||
using type _LIBCPP_NODEBUG = input_iterator_tag;
|
||||
};
|
||||
|
||||
// [iterator.traits]/3.2.3.1
|
||||
// `random_access_iterator_tag` if `I` satisfies `cpp17-random-access-iterator`, or otherwise
|
||||
template <__iterator_traits_detail::__cpp17_random_access_iterator _Ip>
|
||||
struct __deduce_iterator_category<_Ip> {
|
||||
using type = random_access_iterator_tag;
|
||||
using type _LIBCPP_NODEBUG = random_access_iterator_tag;
|
||||
};
|
||||
|
||||
// [iterator.traits]/3.2.3.2
|
||||
// `bidirectional_iterator_tag` if `I` satisfies `cpp17-bidirectional-iterator`, or otherwise
|
||||
template <__iterator_traits_detail::__cpp17_bidirectional_iterator _Ip>
|
||||
struct __deduce_iterator_category<_Ip> {
|
||||
using type = bidirectional_iterator_tag;
|
||||
using type _LIBCPP_NODEBUG = bidirectional_iterator_tag;
|
||||
};
|
||||
|
||||
// [iterator.traits]/3.2.3.3
|
||||
// `forward_iterator_tag` if `I` satisfies `cpp17-forward-iterator`, or otherwise
|
||||
template <__iterator_traits_detail::__cpp17_forward_iterator _Ip>
|
||||
struct __deduce_iterator_category<_Ip> {
|
||||
using type = forward_iterator_tag;
|
||||
using type _LIBCPP_NODEBUG = forward_iterator_tag;
|
||||
};
|
||||
|
||||
template <class _Ip>
|
||||
@ -306,13 +308,13 @@ struct __iterator_traits_iterator_category : __deduce_iterator_category<_Ip> {};
|
||||
// that type.
|
||||
template <__has_member_iterator_category _Ip>
|
||||
struct __iterator_traits_iterator_category<_Ip> {
|
||||
using type = typename _Ip::iterator_category;
|
||||
using type _LIBCPP_NODEBUG = typename _Ip::iterator_category;
|
||||
};
|
||||
|
||||
// otherwise, it names void.
|
||||
template <class>
|
||||
struct __iterator_traits_difference_type {
|
||||
using type = void;
|
||||
using type _LIBCPP_NODEBUG = void;
|
||||
};
|
||||
|
||||
// If the qualified-id `incrementable_traits<I>::difference_type` is valid and denotes a type, then
|
||||
@ -320,7 +322,7 @@ struct __iterator_traits_difference_type {
|
||||
template <class _Ip>
|
||||
requires requires { typename incrementable_traits<_Ip>::difference_type; }
|
||||
struct __iterator_traits_difference_type<_Ip> {
|
||||
using type = typename incrementable_traits<_Ip>::difference_type;
|
||||
using type _LIBCPP_NODEBUG = typename incrementable_traits<_Ip>::difference_type;
|
||||
};
|
||||
|
||||
// [iterator.traits]/3.4
|
||||
|
@ -440,13 +440,13 @@ struct __make_dextents;
|
||||
|
||||
template <class _IndexType, size_t _Rank, size_t... _ExtentsPack>
|
||||
struct __make_dextents< _IndexType, _Rank, extents<_IndexType, _ExtentsPack...>> {
|
||||
using type =
|
||||
using type _LIBCPP_NODEBUG =
|
||||
typename __make_dextents< _IndexType, _Rank - 1, extents<_IndexType, dynamic_extent, _ExtentsPack...>>::type;
|
||||
};
|
||||
|
||||
template <class _IndexType, size_t... _ExtentsPack>
|
||||
struct __make_dextents< _IndexType, 0, extents<_IndexType, _ExtentsPack...>> {
|
||||
using type = extents<_IndexType, _ExtentsPack...>;
|
||||
using type _LIBCPP_NODEBUG = extents<_IndexType, _ExtentsPack...>;
|
||||
};
|
||||
|
||||
} // namespace __mdspan_detail
|
||||
|
@ -259,20 +259,20 @@ struct __pointer_of {};
|
||||
template <class _Tp>
|
||||
requires(__has_pointer<_Tp>::value)
|
||||
struct __pointer_of<_Tp> {
|
||||
using type = typename _Tp::pointer;
|
||||
using type _LIBCPP_NODEBUG = typename _Tp::pointer;
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
requires(!__has_pointer<_Tp>::value && __has_element_type<_Tp>::value)
|
||||
struct __pointer_of<_Tp> {
|
||||
using type = typename _Tp::element_type*;
|
||||
using type _LIBCPP_NODEBUG = typename _Tp::element_type*;
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
requires(!__has_pointer<_Tp>::value && !__has_element_type<_Tp>::value &&
|
||||
__has_element_type<pointer_traits<_Tp>>::value)
|
||||
struct __pointer_of<_Tp> {
|
||||
using type = typename pointer_traits<_Tp>::element_type*;
|
||||
using type _LIBCPP_NODEBUG = typename pointer_traits<_Tp>::element_type*;
|
||||
};
|
||||
|
||||
template <typename _Tp>
|
||||
|
@ -185,22 +185,22 @@ struct __passthrough_type;
|
||||
|
||||
template <class _Tp, size_t _Extent>
|
||||
struct __passthrough_type<span<_Tp, _Extent>> {
|
||||
using type = span<_Tp>;
|
||||
using type _LIBCPP_NODEBUG = span<_Tp>;
|
||||
};
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
struct __passthrough_type<basic_string_view<_CharT, _Traits>> {
|
||||
using type = basic_string_view<_CharT, _Traits>;
|
||||
using type _LIBCPP_NODEBUG = basic_string_view<_CharT, _Traits>;
|
||||
};
|
||||
|
||||
template <class _Np, class _Bound>
|
||||
struct __passthrough_type<iota_view<_Np, _Bound>> {
|
||||
using type = iota_view<_Np, _Bound>;
|
||||
using type _LIBCPP_NODEBUG = iota_view<_Np, _Bound>;
|
||||
};
|
||||
|
||||
template <class _Iter, class _Sent, subrange_kind _Kind>
|
||||
struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> {
|
||||
using type = subrange<_Iter, _Sent, _Kind>;
|
||||
using type _LIBCPP_NODEBUG = subrange<_Iter, _Sent, _Kind>;
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
|
@ -52,12 +52,12 @@ concept __integer_like_with_usable_difference_type =
|
||||
|
||||
template <class _Tp>
|
||||
struct __repeat_view_iterator_difference {
|
||||
using type = _IotaDiffT<_Tp>;
|
||||
using type _LIBCPP_NODEBUG = _IotaDiffT<_Tp>;
|
||||
};
|
||||
|
||||
template <__signed_integer_like _Tp>
|
||||
struct __repeat_view_iterator_difference<_Tp> {
|
||||
using type = _Tp;
|
||||
using type _LIBCPP_NODEBUG = _Tp;
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
|
@ -144,13 +144,13 @@ inline constexpr bool __is_unsized_reverse_subrange<subrange<reverse_iterator<_I
|
||||
|
||||
template <class _Tp>
|
||||
struct __unwrapped_reverse_subrange {
|
||||
using type =
|
||||
using type _LIBCPP_NODEBUG =
|
||||
void; // avoid SFINAE-ing out the overload below -- let the concept requirements do it for better diagnostics
|
||||
};
|
||||
|
||||
template <class _Iter, subrange_kind _Kind>
|
||||
struct __unwrapped_reverse_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, _Kind>> {
|
||||
using type = subrange<_Iter, _Iter, _Kind>;
|
||||
using type _LIBCPP_NODEBUG = subrange<_Iter, _Iter, _Kind>;
|
||||
};
|
||||
|
||||
struct __fn : __range_adaptor_closure<__fn> {
|
||||
|
@ -247,22 +247,22 @@ struct tuple_size<ranges::subrange<_Ip, _Sp, _Kp>> : integral_constant<size_t, 2
|
||||
|
||||
template <class _Ip, class _Sp, ranges::subrange_kind _Kp>
|
||||
struct tuple_element<0, ranges::subrange<_Ip, _Sp, _Kp>> {
|
||||
using type = _Ip;
|
||||
using type _LIBCPP_NODEBUG = _Ip;
|
||||
};
|
||||
|
||||
template <class _Ip, class _Sp, ranges::subrange_kind _Kp>
|
||||
struct tuple_element<1, ranges::subrange<_Ip, _Sp, _Kp>> {
|
||||
using type = _Sp;
|
||||
using type _LIBCPP_NODEBUG = _Sp;
|
||||
};
|
||||
|
||||
template <class _Ip, class _Sp, ranges::subrange_kind _Kp>
|
||||
struct tuple_element<0, const ranges::subrange<_Ip, _Sp, _Kp>> {
|
||||
using type = _Ip;
|
||||
using type _LIBCPP_NODEBUG = _Ip;
|
||||
};
|
||||
|
||||
template <class _Ip, class _Sp, ranges::subrange_kind _Kp>
|
||||
struct tuple_element<1, const ranges::subrange<_Ip, _Sp, _Kp>> {
|
||||
using type = _Sp;
|
||||
using type _LIBCPP_NODEBUG = _Sp;
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_STD_VER >= 20
|
||||
|
@ -229,18 +229,18 @@ struct __passthrough_type;
|
||||
|
||||
template <class _Tp, size_t _Extent>
|
||||
struct __passthrough_type<span<_Tp, _Extent>> {
|
||||
using type = span<_Tp>;
|
||||
using type _LIBCPP_NODEBUG = span<_Tp>;
|
||||
};
|
||||
|
||||
template <class _CharT, class _Traits>
|
||||
struct __passthrough_type<basic_string_view<_CharT, _Traits>> {
|
||||
using type = basic_string_view<_CharT, _Traits>;
|
||||
using type _LIBCPP_NODEBUG = basic_string_view<_CharT, _Traits>;
|
||||
};
|
||||
|
||||
template <class _Iter, class _Sent, subrange_kind _Kind>
|
||||
requires requires { typename subrange<_Iter>; }
|
||||
struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> {
|
||||
using type = subrange<_Iter>;
|
||||
using type _LIBCPP_NODEBUG = subrange<_Iter>;
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
|
@ -136,22 +136,22 @@ transform_view(_Range&&, _Fn) -> transform_view<views::all_t<_Range>, _Fn>;
|
||||
|
||||
template <class _View>
|
||||
struct __transform_view_iterator_concept {
|
||||
using type = input_iterator_tag;
|
||||
using type _LIBCPP_NODEBUG = input_iterator_tag;
|
||||
};
|
||||
|
||||
template <random_access_range _View>
|
||||
struct __transform_view_iterator_concept<_View> {
|
||||
using type = random_access_iterator_tag;
|
||||
using type _LIBCPP_NODEBUG = random_access_iterator_tag;
|
||||
};
|
||||
|
||||
template <bidirectional_range _View>
|
||||
struct __transform_view_iterator_concept<_View> {
|
||||
using type = bidirectional_iterator_tag;
|
||||
using type _LIBCPP_NODEBUG = bidirectional_iterator_tag;
|
||||
};
|
||||
|
||||
template <forward_range _View>
|
||||
struct __transform_view_iterator_concept<_View> {
|
||||
using type = forward_iterator_tag;
|
||||
using type _LIBCPP_NODEBUG = forward_iterator_tag;
|
||||
};
|
||||
|
||||
template <class, class>
|
||||
|
@ -60,7 +60,7 @@ struct __make_tuple_types {
|
||||
static_assert(_Sp <= _Ep, "__make_tuple_types input error");
|
||||
using _RawTp _LIBCPP_NODEBUG = __remove_cvref_t<_Tp>;
|
||||
using _Maker _LIBCPP_NODEBUG = __make_tuple_types_flat<_RawTp, typename __make_tuple_indices<_Ep, _Sp>::type>;
|
||||
using type = typename _Maker::template __apply_quals<_Tp>;
|
||||
using type _LIBCPP_NODEBUG = typename _Maker::template __apply_quals<_Tp>;
|
||||
};
|
||||
|
||||
template <class... _Types, size_t _Ep>
|
||||
|
@ -41,7 +41,7 @@ using __add_rvalue_reference_t = typename __add_rvalue_reference_impl<_Tp>::type
|
||||
|
||||
template <class _Tp>
|
||||
struct _LIBCPP_NO_SPECIALIZATIONS add_rvalue_reference {
|
||||
using type = __add_rvalue_reference_t<_Tp>;
|
||||
using type _LIBCPP_NODEBUG = __add_rvalue_reference_t<_Tp>;
|
||||
};
|
||||
|
||||
#if _LIBCPP_STD_VER >= 14
|
||||
|
@ -121,7 +121,7 @@ struct common_reference<> {};
|
||||
// bullet 2 - sizeof...(T) == 1
|
||||
template <class _Tp>
|
||||
struct common_reference<_Tp> {
|
||||
using type = _Tp;
|
||||
using type _LIBCPP_NODEBUG = _Tp;
|
||||
};
|
||||
|
||||
// bullet 3 - sizeof...(T) == 2
|
||||
@ -140,7 +140,7 @@ struct common_reference<_Tp, _Up> : __common_reference_sub_bullet1<_Tp, _Up> {};
|
||||
template <class _Tp, class _Up>
|
||||
requires is_reference_v<_Tp> && is_reference_v<_Up> && requires { typename __common_ref_t<_Tp, _Up>; }
|
||||
struct __common_reference_sub_bullet1<_Tp, _Up> {
|
||||
using type = __common_ref_t<_Tp, _Up>;
|
||||
using type _LIBCPP_NODEBUG = __common_ref_t<_Tp, _Up>;
|
||||
};
|
||||
|
||||
// sub-bullet 2 - Otherwise, if basic_common_reference<remove_cvref_t<T1>, remove_cvref_t<T2>, XREF(T1), XREF(T2)>::type
|
||||
@ -158,7 +158,7 @@ using __basic_common_reference_t _LIBCPP_NODEBUG =
|
||||
template <class _Tp, class _Up>
|
||||
requires requires { typename __basic_common_reference_t<_Tp, _Up>; }
|
||||
struct __common_reference_sub_bullet2<_Tp, _Up> {
|
||||
using type = __basic_common_reference_t<_Tp, _Up>;
|
||||
using type _LIBCPP_NODEBUG = __basic_common_reference_t<_Tp, _Up>;
|
||||
};
|
||||
|
||||
// sub-bullet 3 - Otherwise, if COND-RES(T1, T2) is well-formed,
|
||||
@ -166,7 +166,7 @@ struct __common_reference_sub_bullet2<_Tp, _Up> {
|
||||
template <class _Tp, class _Up>
|
||||
requires requires { typename __cond_res<_Tp, _Up>; }
|
||||
struct __common_reference_sub_bullet3<_Tp, _Up> {
|
||||
using type = __cond_res<_Tp, _Up>;
|
||||
using type _LIBCPP_NODEBUG = __cond_res<_Tp, _Up>;
|
||||
};
|
||||
|
||||
// sub-bullet 4 & 5 - Otherwise, if common_type_t<T1, T2> is well-formed,
|
||||
|
@ -48,7 +48,7 @@ struct __common_type3 {};
|
||||
// sub-bullet 4 - "if COND_RES(CREF(D1), CREF(D2)) denotes a type..."
|
||||
template <class _Tp, class _Up>
|
||||
struct __common_type3<_Tp, _Up, void_t<__cond_type<const _Tp&, const _Up&>>> {
|
||||
using type = remove_cvref_t<__cond_type<const _Tp&, const _Up&>>;
|
||||
using type _LIBCPP_NODEBUG = remove_cvref_t<__cond_type<const _Tp&, const _Up&>>;
|
||||
};
|
||||
|
||||
template <class _Tp, class _Up, class = void>
|
||||
|
@ -26,52 +26,52 @@ struct __strip_signature;
|
||||
|
||||
template <class _Rp, class... _Args>
|
||||
struct __strip_signature<_Rp (*)(_Args...)> {
|
||||
using type = _Rp(_Args...);
|
||||
using type _LIBCPP_NODEBUG = _Rp(_Args...);
|
||||
};
|
||||
|
||||
template <class _Rp, class... _Args>
|
||||
struct __strip_signature<_Rp (*)(_Args...) noexcept> {
|
||||
using type = _Rp(_Args...);
|
||||
using type _LIBCPP_NODEBUG = _Rp(_Args...);
|
||||
};
|
||||
|
||||
# endif // defined(__cpp_static_call_operator) && __cpp_static_call_operator >= 202207L
|
||||
|
||||
// clang-format off
|
||||
template<class _Rp, class _Gp, class ..._Ap>
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...)> { using type = _Rp(_Ap...); };
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...)> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
|
||||
template<class _Rp, class _Gp, class ..._Ap>
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) const> { using type = _Rp(_Ap...); };
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) const> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
|
||||
template<class _Rp, class _Gp, class ..._Ap>
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile> { using type = _Rp(_Ap...); };
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
|
||||
template<class _Rp, class _Gp, class ..._Ap>
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile> { using type = _Rp(_Ap...); };
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
|
||||
|
||||
template<class _Rp, class _Gp, class ..._Ap>
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) &> { using type = _Rp(_Ap...); };
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) &> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
|
||||
template<class _Rp, class _Gp, class ..._Ap>
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) const &> { using type = _Rp(_Ap...); };
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) const &> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
|
||||
template<class _Rp, class _Gp, class ..._Ap>
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile &> { using type = _Rp(_Ap...); };
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile &> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
|
||||
template<class _Rp, class _Gp, class ..._Ap>
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile &> { using type = _Rp(_Ap...); };
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile &> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
|
||||
|
||||
template<class _Rp, class _Gp, class ..._Ap>
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) noexcept> { using type = _Rp(_Ap...); };
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) noexcept> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
|
||||
template<class _Rp, class _Gp, class ..._Ap>
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) const noexcept> { using type = _Rp(_Ap...); };
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) const noexcept> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
|
||||
template<class _Rp, class _Gp, class ..._Ap>
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile noexcept> { using type = _Rp(_Ap...); };
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile noexcept> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
|
||||
template<class _Rp, class _Gp, class ..._Ap>
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile noexcept> { using type = _Rp(_Ap...); };
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile noexcept> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
|
||||
|
||||
template<class _Rp, class _Gp, class ..._Ap>
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) & noexcept> { using type = _Rp(_Ap...); };
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) & noexcept> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
|
||||
template<class _Rp, class _Gp, class ..._Ap>
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) const & noexcept> { using type = _Rp(_Ap...); };
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) const & noexcept> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
|
||||
template<class _Rp, class _Gp, class ..._Ap>
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile & noexcept> { using type = _Rp(_Ap...); };
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile & noexcept> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
|
||||
template<class _Rp, class _Gp, class ..._Ap>
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile & noexcept> { using type = _Rp(_Ap...); };
|
||||
struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile & noexcept> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
|
||||
// clang-format on
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
@ -503,13 +503,14 @@ template <class _T1, class _T2, class _U1, class _U2, template <class> class _TQ
|
||||
typename pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>, common_reference_t<_TQual<_T2>, _UQual<_U2>>>;
|
||||
}
|
||||
struct basic_common_reference<pair<_T1, _T2>, pair<_U1, _U2>, _TQual, _UQual> {
|
||||
using type = pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>, common_reference_t<_TQual<_T2>, _UQual<_U2>>>;
|
||||
using type _LIBCPP_NODEBUG =
|
||||
pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>, common_reference_t<_TQual<_T2>, _UQual<_U2>>>;
|
||||
};
|
||||
|
||||
template <class _T1, class _T2, class _U1, class _U2>
|
||||
requires requires { typename pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>; }
|
||||
struct common_type<pair<_T1, _T2>, pair<_U1, _U2>> {
|
||||
using type = pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>;
|
||||
using type _LIBCPP_NODEBUG = pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>;
|
||||
};
|
||||
#endif // _LIBCPP_STD_VER >= 23
|
||||
|
||||
|
@ -497,7 +497,7 @@ struct _LIBCPP_TEMPLATE_VIS tuple_size<array<_Tp, _Size> > : public integral_con
|
||||
template <size_t _Ip, class _Tp, size_t _Size>
|
||||
struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> > {
|
||||
static_assert(_Ip < _Size, "Index out of bounds in std::tuple_element<> (std::array)");
|
||||
using type = _Tp;
|
||||
using type _LIBCPP_NODEBUG = _Tp;
|
||||
};
|
||||
|
||||
template <size_t _Ip, class _Tp, size_t _Size>
|
||||
|
@ -1394,7 +1394,7 @@ struct tuple_size<complex<_Tp>> : integral_constant<size_t, 2> {};
|
||||
template <size_t _Ip, class _Tp>
|
||||
struct tuple_element<_Ip, complex<_Tp>> {
|
||||
static_assert(_Ip < 2, "Index value is out of range.");
|
||||
using type = _Tp;
|
||||
using type _LIBCPP_NODEBUG = _Tp;
|
||||
};
|
||||
|
||||
template <size_t _Ip, class _Xp>
|
||||
|
@ -49,7 +49,7 @@ using native = __vec_ext<_LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES / sizeof(_Tp)>;
|
||||
// TODO: make this platform dependent
|
||||
template <class _Tp, size_t _Np, class... _Abis>
|
||||
struct deduce {
|
||||
using type = fixed_size<_Np>;
|
||||
using type _LIBCPP_NODEBUG = fixed_size<_Np>;
|
||||
};
|
||||
|
||||
// TODO: make this platform dependent
|
||||
|
@ -1032,13 +1032,13 @@ _LIBCPP_DIAGNOSTIC_POP
|
||||
template <class... _TTypes, class... _UTypes, template <class> class _TQual, template <class> class _UQual>
|
||||
requires requires { typename tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>; }
|
||||
struct basic_common_reference<tuple<_TTypes...>, tuple<_UTypes...>, _TQual, _UQual> {
|
||||
using type = tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>;
|
||||
using type _LIBCPP_NODEBUG = tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>;
|
||||
};
|
||||
|
||||
template <class... _TTypes, class... _UTypes>
|
||||
requires requires { typename tuple<common_type_t<_TTypes, _UTypes>...>; }
|
||||
struct common_type<tuple<_TTypes...>, tuple<_UTypes...>> {
|
||||
using type = tuple<common_type_t<_TTypes, _UTypes>...>;
|
||||
using type _LIBCPP_NODEBUG = tuple<common_type_t<_TTypes, _UTypes>...>;
|
||||
};
|
||||
# endif // _LIBCPP_STD_VER >= 23
|
||||
|
||||
|
@ -341,7 +341,7 @@ struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, const volatile _Tp> : add_c
|
||||
template <size_t _Ip, class... _Types>
|
||||
struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, variant<_Types...>> {
|
||||
static_assert(_Ip < sizeof...(_Types), "Index out of bounds in std::variant_alternative<>");
|
||||
using type = __type_pack_element<_Ip, _Types...>;
|
||||
using type _LIBCPP_NODEBUG = __type_pack_element<_Ip, _Types...>;
|
||||
};
|
||||
|
||||
template <size_t _NumAlternatives>
|
||||
|
@ -14,6 +14,7 @@
|
||||
namespace libcpp {
|
||||
namespace {
|
||||
AST_MATCHER(clang::NamedDecl, isPretty) { return !is_ugly_name(Node.getName()); }
|
||||
AST_MATCHER(clang::NamedDecl, isUgly) { return is_ugly_name(Node.getName()); }
|
||||
} // namespace
|
||||
|
||||
nodebug_on_aliases::nodebug_on_aliases(llvm::StringRef name, clang::tidy::ClangTidyContext* context)
|
||||
@ -25,11 +26,29 @@ void nodebug_on_aliases::registerMatchers(clang::ast_matchers::MatchFinder* find
|
||||
typeAliasDecl(unless(anyOf(isPretty(), hasAttr(clang::attr::NoDebug), hasAncestor(functionDecl()))))
|
||||
.bind("nodebug_on_internal_aliases"),
|
||||
this);
|
||||
|
||||
finder->addMatcher(
|
||||
typeAliasDecl(
|
||||
unless(hasAttr(clang::attr::NoDebug)),
|
||||
hasName("type"),
|
||||
hasAncestor(cxxRecordDecl(unless(has(namedDecl(unless(anyOf(
|
||||
typeAliasDecl(hasName("type")),
|
||||
typeAliasDecl(isUgly()),
|
||||
recordDecl(isImplicit()),
|
||||
templateTypeParmDecl(),
|
||||
nonTypeTemplateParmDecl(),
|
||||
templateTemplateParmDecl()))))))))
|
||||
.bind("nodebug_on_type_traits"),
|
||||
this);
|
||||
}
|
||||
|
||||
void nodebug_on_aliases::check(const clang::ast_matchers::MatchFinder::MatchResult& result) {
|
||||
if (const auto* alias = result.Nodes.getNodeAs<clang::TypeAliasDecl>("nodebug_on_internal_aliases")) {
|
||||
diag(alias->getBeginLoc(), "Internal aliases should always be marked _LIBCPP_NODEBUG");
|
||||
}
|
||||
|
||||
if (const auto* alias = result.Nodes.getNodeAs<clang::TypeAliasDecl>("nodebug_on_type_traits")) {
|
||||
diag(alias->getBeginLoc(), "The alias of type traits should always be marked _LIBCPP_NODEBUG");
|
||||
}
|
||||
}
|
||||
} // namespace libcpp
|
||||
|
Loading…
x
Reference in New Issue
Block a user