Skip to content

Commit ced8a0c

Browse files
committed
[libc++] Use [[clang::no_specializations]] to diagnose invalid user specializations
1 parent 976f3a0 commit ced8a0c

File tree

89 files changed

+532
-196
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+532
-196
lines changed

libcxx/include/__compare/compare_three_way_result.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result<
3333
};
3434

3535
template <class _Tp, class _Up = _Tp>
36-
struct _LIBCPP_TEMPLATE_VIS compare_three_way_result : __compare_three_way_result<_Tp, _Up, void> {};
36+
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS compare_three_way_result
37+
: __compare_three_way_result<_Tp, _Up, void> {};
3738

3839
template <class _Tp, class _Up = _Tp>
3940
using compare_three_way_result_t = typename compare_three_way_result<_Tp, _Up>::type;

libcxx/include/__config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,6 +1172,12 @@ typedef __char32_t char32_t;
11721172

11731173
# define _LIBCPP_NODEBUG [[__gnu__::__nodebug__]]
11741174

1175+
# if __has_cpp_attribute(_Clang::__no_specializations__)
1176+
# define _LIBCPP_NO_SPECIALIZATIONS [[_Clang::__no_specializations__]]
1177+
# else
1178+
# define _LIBCPP_NO_SPECIALIZATIONS
1179+
# endif
1180+
11751181
# if __has_attribute(__standalone_debug__)
11761182
# define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__))
11771183
# else

libcxx/include/__cxx03/__type_traits/add_const.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
_LIBCPP_BEGIN_NAMESPACE_STD
1919

2020
template <class _Tp>
21-
struct _LIBCPP_TEMPLATE_VIS add_const {
21+
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DIAGNOSE_SPECIALIZATIONS add_const {
2222
typedef _LIBCPP_NODEBUG const _Tp type;
2323
};
2424

libcxx/include/__cxx03/__type_traits/add_cv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
_LIBCPP_BEGIN_NAMESPACE_STD
1919

2020
template <class _Tp>
21-
struct _LIBCPP_TEMPLATE_VIS add_cv {
21+
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DIAGNOSE_SPECIALIZATIONS add_cv {
2222
typedef _LIBCPP_NODEBUG const volatile _Tp type;
2323
};
2424

libcxx/include/__cxx03/__type_traits/add_volatile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
_LIBCPP_BEGIN_NAMESPACE_STD
1919

2020
template <class _Tp>
21-
struct _LIBCPP_TEMPLATE_VIS add_volatile {
21+
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DIAGNOSE_SPECIALIZATIONS add_volatile {
2222
typedef _LIBCPP_NODEBUG volatile _Tp type;
2323
};
2424

libcxx/include/__format/format_arg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ class __basic_format_arg_value {
277277
};
278278

279279
template <class _Context>
280-
class _LIBCPP_TEMPLATE_VIS basic_format_arg {
280+
class _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS basic_format_arg {
281281
public:
282282
class _LIBCPP_TEMPLATE_VIS handle;
283283

libcxx/include/__ranges/range_adaptor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ template <_RangeAdaptorClosure _Closure, _RangeAdaptorClosure _OtherClosure>
8585
# if _LIBCPP_STD_VER >= 23
8686
template <class _Tp>
8787
requires is_class_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>>
88-
class range_adaptor_closure : public __range_adaptor_closure<_Tp> {};
88+
class _LIBCPP_NO_SPECIALIZATIONS range_adaptor_closure : public __range_adaptor_closure<_Tp> {};
8989
# endif // _LIBCPP_STD_VER >= 23
9090

9191
} // namespace ranges

libcxx/include/__type_traits/add_cv_quals.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
_LIBCPP_BEGIN_NAMESPACE_STD
1919

2020
template <class _Tp>
21-
struct _LIBCPP_TEMPLATE_VIS add_const {
21+
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS add_const {
2222
using type _LIBCPP_NODEBUG = const _Tp;
2323
};
2424

@@ -28,7 +28,7 @@ using add_const_t = typename add_const<_Tp>::type;
2828
#endif
2929

3030
template <class _Tp>
31-
struct _LIBCPP_TEMPLATE_VIS add_cv {
31+
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS add_cv {
3232
using type _LIBCPP_NODEBUG = const volatile _Tp;
3333
};
3434

@@ -38,7 +38,7 @@ using add_cv_t = typename add_cv<_Tp>::type;
3838
#endif
3939

4040
template <class _Tp>
41-
struct _LIBCPP_TEMPLATE_VIS add_volatile {
41+
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS add_volatile {
4242
using type _LIBCPP_NODEBUG = volatile _Tp;
4343
};
4444

libcxx/include/__type_traits/add_lvalue_reference.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ using __add_lvalue_reference_t = typename __add_lvalue_reference_impl<_Tp>::type
4040
#endif // __has_builtin(__add_lvalue_reference)
4141

4242
template <class _Tp>
43-
struct add_lvalue_reference {
43+
struct _LIBCPP_NO_SPECIALIZATIONS add_lvalue_reference {
4444
using type _LIBCPP_NODEBUG = __add_lvalue_reference_t<_Tp>;
4545
};
4646

libcxx/include/__type_traits/add_pointer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ using __add_pointer_t = typename __add_pointer_impl<_Tp>::type;
4141
#endif // !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__add_pointer)
4242

4343
template <class _Tp>
44-
struct add_pointer {
44+
struct _LIBCPP_NO_SPECIALIZATIONS add_pointer {
4545
using type _LIBCPP_NODEBUG = __add_pointer_t<_Tp>;
4646
};
4747

0 commit comments

Comments
 (0)