Skip to content

Commit 1638657

Browse files
authored
[libc++][hardening] Categorize more 'valid-element-access' checks. (#71620)
1 parent bffdde8 commit 1638657

File tree

16 files changed

+151
-45
lines changed

16 files changed

+151
-45
lines changed

libcxx/include/__algorithm/ranges_max.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ struct __fn {
5454
indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
5555
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp
5656
operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const {
57-
_LIBCPP_ASSERT_UNCATEGORIZED(__il.begin() != __il.end(), "initializer_list must contain at least one element");
57+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
58+
__il.begin() != __il.end(), "initializer_list must contain at least one element");
5859

5960
auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { return std::invoke(__comp, __rhs, __lhs); };
6061
return *ranges::__min_element_impl(__il.begin(), __il.end(), __comp_lhs_rhs_swapped, __proj);
@@ -69,7 +70,7 @@ struct __fn {
6970
auto __first = ranges::begin(__r);
7071
auto __last = ranges::end(__r);
7172

72-
_LIBCPP_ASSERT_UNCATEGORIZED(__first != __last, "range must contain at least one element");
73+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__first != __last, "range must contain at least one element");
7374

7475
if constexpr (forward_range<_Rp> && !__is_cheap_to_copy<range_value_t<_Rp>>) {
7576
auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool {

libcxx/include/__algorithm/ranges_min.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ struct __fn {
5353
indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
5454
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp
5555
operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const {
56-
_LIBCPP_ASSERT_UNCATEGORIZED(__il.begin() != __il.end(), "initializer_list must contain at least one element");
56+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
57+
__il.begin() != __il.end(), "initializer_list must contain at least one element");
5758
return *ranges::__min_element_impl(__il.begin(), __il.end(), __comp, __proj);
5859
}
5960

@@ -65,7 +66,7 @@ struct __fn {
6566
operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
6667
auto __first = ranges::begin(__r);
6768
auto __last = ranges::end(__r);
68-
_LIBCPP_ASSERT_UNCATEGORIZED(__first != __last, "range must contain at least one element");
69+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__first != __last, "range must contain at least one element");
6970
if constexpr (forward_range<_Rp> && !__is_cheap_to_copy<range_value_t<_Rp>>) {
7071
return *ranges::__min_element_impl(__first, __last, __comp, __proj);
7172
} else {

libcxx/include/__algorithm/ranges_minmax.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ struct __fn {
6565
indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>
6666
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result<_Type>
6767
operator()(initializer_list<_Type> __il, _Comp __comp = {}, _Proj __proj = {}) const {
68-
_LIBCPP_ASSERT_UNCATEGORIZED(__il.begin() != __il.end(), "initializer_list has to contain at least one element");
68+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
69+
__il.begin() != __il.end(), "initializer_list has to contain at least one element");
6970
auto __iters = std::__minmax_element_impl(__il.begin(), __il.end(), __comp, __proj);
7071
return ranges::minmax_result<_Type>{*__iters.first, *__iters.second};
7172
}
@@ -80,7 +81,7 @@ struct __fn {
8081
auto __last = ranges::end(__r);
8182
using _ValueT = range_value_t<_Range>;
8283

83-
_LIBCPP_ASSERT_UNCATEGORIZED(__first != __last, "range has to contain at least one element");
84+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__first != __last, "range has to contain at least one element");
8485

8586
if constexpr (forward_range<_Range>) {
8687
// Special-case the one element case. Avoid repeatedly initializing objects from the result of an iterator

libcxx/include/__algorithm/sample.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ _LIBCPP_HIDE_FROM_ABI _SampleIterator __sample(
8989
_SampleIterator __output_iter,
9090
_Distance __n,
9191
_UniformRandomNumberGenerator& __g) {
92-
_LIBCPP_ASSERT_UNCATEGORIZED(__n >= 0, "N must be a positive number.");
92+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n >= 0, "N must be a positive number.");
9393

9494
using _PopIterCategory = typename _IterOps<_AlgPolicy>::template __iterator_category<_PopulationIterator>;
9595
using _Difference = typename _IterOps<_AlgPolicy>::template __difference_type<_PopulationIterator>;

libcxx/include/__format/formatter_output.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ __write(_Iterator __first,
246246
output_iterator<const iter_value_t<_Iterator>&> auto __out_it,
247247
__format_spec::__parsed_specifications<_ParserCharT> __specs,
248248
ptrdiff_t __size) -> decltype(__out_it) {
249-
_LIBCPP_ASSERT_UNCATEGORIZED(__first <= __last, "Not a valid range");
249+
_LIBCPP_ASSERT_VALID_INPUT_RANGE(__first <= __last, "Not a valid range");
250250
return __formatter::__write(basic_string_view{__first, __last}, std::move(__out_it), __specs, __size);
251251
}
252252

@@ -259,7 +259,7 @@ __write(_Iterator __first,
259259
_Iterator __last,
260260
output_iterator<const iter_value_t<_Iterator>&> auto __out_it,
261261
__format_spec::__parsed_specifications<_ParserCharT> __specs) -> decltype(__out_it) {
262-
_LIBCPP_ASSERT_UNCATEGORIZED(__first <= __last, "Not a valid range");
262+
_LIBCPP_ASSERT_VALID_INPUT_RANGE(__first <= __last, "Not a valid range");
263263
return __formatter::__write(__first, __last, std::move(__out_it), __specs, __last - __first);
264264
}
265265

@@ -273,7 +273,7 @@ _LIBCPP_HIDE_FROM_ABI auto __write_transformed(
273273
output_iterator<const _CharT&> auto __out_it,
274274
__format_spec::__parsed_specifications<_ParserCharT> __specs,
275275
_UnaryOperation __op) -> decltype(__out_it) {
276-
_LIBCPP_ASSERT_UNCATEGORIZED(__first <= __last, "Not a valid range");
276+
_LIBCPP_ASSERT_VALID_INPUT_RANGE(__first <= __last, "Not a valid range");
277277

278278
ptrdiff_t __size = __last - __first;
279279
if (__size >= __specs.__width_)

libcxx/include/__format/parser_std_format_spec.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ class _LIBCPP_TEMPLATE_VIS __parser {
591591
|| (same_as<_CharT, wchar_t> && sizeof(wchar_t) == 2)
592592
# endif
593593
_LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end, bool __use_range_fill) {
594-
_LIBCPP_ASSERT_UNCATEGORIZED(
594+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
595595
__begin != __end,
596596
"when called with an empty input the function will cause "
597597
"undefined behavior by evaluating data not in the input");
@@ -624,7 +624,7 @@ class _LIBCPP_TEMPLATE_VIS __parser {
624624
template <contiguous_iterator _Iterator>
625625
requires(same_as<_CharT, wchar_t> && sizeof(wchar_t) == 4)
626626
_LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end, bool __use_range_fill) {
627-
_LIBCPP_ASSERT_UNCATEGORIZED(
627+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
628628
__begin != __end,
629629
"when called with an empty input the function will cause "
630630
"undefined behavior by evaluating data not in the input");
@@ -652,7 +652,7 @@ class _LIBCPP_TEMPLATE_VIS __parser {
652652
// range-fill and tuple-fill are identical
653653
template <contiguous_iterator _Iterator>
654654
_LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end, bool __use_range_fill) {
655-
_LIBCPP_ASSERT_UNCATEGORIZED(
655+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
656656
__begin != __end,
657657
"when called with an empty input the function will cause "
658658
"undefined behavior by evaluating data not in the input");

libcxx/include/__iterator/common_iterator.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class common_iterator {
7777
requires convertible_to<const _I2&, _Iter> && convertible_to<const _S2&, _Sent>
7878
_LIBCPP_HIDE_FROM_ABI constexpr common_iterator(const common_iterator<_I2, _S2>& __other)
7979
: __hold_([&]() -> variant<_Iter, _Sent> {
80-
_LIBCPP_ASSERT_UNCATEGORIZED(
80+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
8181
!__other.__hold_.valueless_by_exception(), "Attempted to construct from a valueless common_iterator");
8282
if (__other.__hold_.index() == 0)
8383
return variant<_Iter, _Sent>{in_place_index<0>, std::__unchecked_get<0>(__other.__hold_)};
@@ -88,7 +88,7 @@ class common_iterator {
8888
requires convertible_to<const _I2&, _Iter> && convertible_to<const _S2&, _Sent> &&
8989
assignable_from<_Iter&, const _I2&> && assignable_from<_Sent&, const _S2&>
9090
_LIBCPP_HIDE_FROM_ABI common_iterator& operator=(const common_iterator<_I2, _S2>& __other) {
91-
_LIBCPP_ASSERT_UNCATEGORIZED(
91+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
9292
!__other.__hold_.valueless_by_exception(), "Attempted to assign from a valueless common_iterator");
9393

9494
auto __idx = __hold_.index();
@@ -110,15 +110,15 @@ class common_iterator {
110110
}
111111

112112
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() {
113-
_LIBCPP_ASSERT_UNCATEGORIZED(
113+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
114114
std::holds_alternative<_Iter>(__hold_), "Attempted to dereference a non-dereferenceable common_iterator");
115115
return *std::__unchecked_get<_Iter>(__hold_);
116116
}
117117

118118
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const
119119
requires __dereferenceable<const _Iter>
120120
{
121-
_LIBCPP_ASSERT_UNCATEGORIZED(
121+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
122122
std::holds_alternative<_Iter>(__hold_), "Attempted to dereference a non-dereferenceable common_iterator");
123123
return *std::__unchecked_get<_Iter>(__hold_);
124124
}
@@ -129,7 +129,7 @@ class common_iterator {
129129
__i.operator->();
130130
} || is_reference_v<iter_reference_t<_I2>> || constructible_from<iter_value_t<_I2>, iter_reference_t<_I2>>)
131131
{
132-
_LIBCPP_ASSERT_UNCATEGORIZED(
132+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
133133
std::holds_alternative<_Iter>(__hold_), "Attempted to dereference a non-dereferenceable common_iterator");
134134
if constexpr (is_pointer_v<_Iter> || requires(const _Iter& __i) { __i.operator->(); }) {
135135
return std::__unchecked_get<_Iter>(__hold_);
@@ -142,14 +142,14 @@ class common_iterator {
142142
}
143143

144144
_LIBCPP_HIDE_FROM_ABI common_iterator& operator++() {
145-
_LIBCPP_ASSERT_UNCATEGORIZED(
145+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
146146
std::holds_alternative<_Iter>(__hold_), "Attempted to increment a non-dereferenceable common_iterator");
147147
++std::__unchecked_get<_Iter>(__hold_);
148148
return *this;
149149
}
150150

151151
_LIBCPP_HIDE_FROM_ABI decltype(auto) operator++(int) {
152-
_LIBCPP_ASSERT_UNCATEGORIZED(
152+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
153153
std::holds_alternative<_Iter>(__hold_), "Attempted to increment a non-dereferenceable common_iterator");
154154
if constexpr (forward_iterator<_Iter>) {
155155
auto __tmp = *this;
@@ -170,9 +170,9 @@ class common_iterator {
170170
requires sentinel_for<_Sent, _I2>
171171
_LIBCPP_HIDE_FROM_ABI friend constexpr bool
172172
operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) {
173-
_LIBCPP_ASSERT_UNCATEGORIZED(
173+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
174174
!__x.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator");
175-
_LIBCPP_ASSERT_UNCATEGORIZED(
175+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
176176
!__y.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator");
177177

178178
auto __x_index = __x.__hold_.index();
@@ -191,9 +191,9 @@ class common_iterator {
191191
requires sentinel_for<_Sent, _I2> && equality_comparable_with<_Iter, _I2>
192192
_LIBCPP_HIDE_FROM_ABI friend constexpr bool
193193
operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) {
194-
_LIBCPP_ASSERT_UNCATEGORIZED(
194+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
195195
!__x.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator");
196-
_LIBCPP_ASSERT_UNCATEGORIZED(
196+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
197197
!__y.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator");
198198

199199
auto __x_index = __x.__hold_.index();
@@ -215,9 +215,9 @@ class common_iterator {
215215
requires sized_sentinel_for<_Sent, _I2>
216216
_LIBCPP_HIDE_FROM_ABI friend constexpr iter_difference_t<_I2>
217217
operator-(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) {
218-
_LIBCPP_ASSERT_UNCATEGORIZED(
218+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
219219
!__x.__hold_.valueless_by_exception(), "Attempted to subtract from a valueless common_iterator");
220-
_LIBCPP_ASSERT_UNCATEGORIZED(
220+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
221221
!__y.__hold_.valueless_by_exception(), "Attempted to subtract a valueless common_iterator");
222222

223223
auto __x_index = __x.__hold_.index();
@@ -239,7 +239,7 @@ class common_iterator {
239239
iter_move(const common_iterator& __i) noexcept(noexcept(ranges::iter_move(std::declval<const _Iter&>())))
240240
requires input_iterator<_Iter>
241241
{
242-
_LIBCPP_ASSERT_UNCATEGORIZED(
242+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
243243
std::holds_alternative<_Iter>(__i.__hold_), "Attempted to iter_move a non-dereferenceable common_iterator");
244244
return ranges::iter_move(std::__unchecked_get<_Iter>(__i.__hold_));
245245
}
@@ -248,9 +248,9 @@ class common_iterator {
248248
_LIBCPP_HIDE_FROM_ABI friend constexpr void
249249
iter_swap(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) noexcept(
250250
noexcept(ranges::iter_swap(std::declval<const _Iter&>(), std::declval<const _I2&>()))) {
251-
_LIBCPP_ASSERT_UNCATEGORIZED(
251+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
252252
std::holds_alternative<_Iter>(__x.__hold_), "Attempted to iter_swap a non-dereferenceable common_iterator");
253-
_LIBCPP_ASSERT_UNCATEGORIZED(
253+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
254254
std::holds_alternative<_I2>(__y.__hold_), "Attempted to iter_swap a non-dereferenceable common_iterator");
255255
return ranges::iter_swap(std::__unchecked_get<_Iter>(__x.__hold_), std::__unchecked_get<_I2>(__y.__hold_));
256256
}

libcxx/include/__iterator/counted_iterator.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ class counted_iterator
105105
_LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter> count() const noexcept { return __count_; }
106106

107107
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() {
108-
_LIBCPP_ASSERT_UNCATEGORIZED(__count_ > 0, "Iterator is equal to or past end.");
108+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__count_ > 0, "Iterator is equal to or past end.");
109109
return *__current_;
110110
}
111111

112112
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const
113113
requires __dereferenceable<const _Iter>
114114
{
115-
_LIBCPP_ASSERT_UNCATEGORIZED(__count_ > 0, "Iterator is equal to or past end.");
115+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__count_ > 0, "Iterator is equal to or past end.");
116116
return *__current_;
117117
}
118118

@@ -229,7 +229,7 @@ class counted_iterator
229229
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](iter_difference_t<_Iter> __n) const
230230
requires random_access_iterator<_Iter>
231231
{
232-
_LIBCPP_ASSERT_UNCATEGORIZED(__n < __count_, "Subscript argument must be less than size.");
232+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < __count_, "Subscript argument must be less than size.");
233233
return __current_[__n];
234234
}
235235

@@ -253,15 +253,16 @@ class counted_iterator
253253
iter_move(const counted_iterator& __i) noexcept(noexcept(ranges::iter_move(__i.__current_)))
254254
requires input_iterator<_Iter>
255255
{
256-
_LIBCPP_ASSERT_UNCATEGORIZED(__i.__count_ > 0, "Iterator must not be past end of range.");
256+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i.__count_ > 0, "Iterator must not be past end of range.");
257257
return ranges::iter_move(__i.__current_);
258258
}
259259

260260
template <indirectly_swappable<_Iter> _I2>
261261
_LIBCPP_HIDE_FROM_ABI friend constexpr void
262262
iter_swap(const counted_iterator& __x,
263263
const counted_iterator<_I2>& __y) noexcept(noexcept(ranges::iter_swap(__x.__current_, __y.__current_))) {
264-
_LIBCPP_ASSERT_UNCATEGORIZED(__x.__count_ > 0 && __y.__count_ > 0, "Iterators must not be past end of range.");
264+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
265+
__x.__count_ > 0 && __y.__count_ > 0, "Iterators must not be past end of range.");
265266
return ranges::iter_swap(__x.__current_, __y.__current_);
266267
}
267268

libcxx/include/__ranges/subrange.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ class _LIBCPP_TEMPLATE_VIS subrange : public view_interface<subrange<_Iter, _Sen
101101
requires(_Kind == subrange_kind::sized)
102102
: __begin_(std::move(__iter)), __end_(std::move(__sent)), __size_(__n) {
103103
if constexpr (sized_sentinel_for<_Sent, _Iter>)
104-
_LIBCPP_ASSERT_UNCATEGORIZED((__end_ - __begin_) == static_cast<iter_difference_t<_Iter>>(__n),
105-
"std::ranges::subrange was passed an invalid size hint");
104+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS((__end_ - __begin_) == static_cast<iter_difference_t<_Iter>>(__n),
105+
"std::ranges::subrange was passed an invalid size hint");
106106
}
107107

108108
template <__different_from<subrange> _Range>

libcxx/include/__ranges/view_interface.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class view_interface {
109109
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) front()
110110
requires forward_range<_D2>
111111
{
112-
_LIBCPP_ASSERT_UNCATEGORIZED(
112+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
113113
!empty(), "Precondition `!empty()` not satisfied. `.front()` called on an empty view.");
114114
return *ranges::begin(__derived());
115115
}
@@ -118,7 +118,7 @@ class view_interface {
118118
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) front() const
119119
requires forward_range<const _D2>
120120
{
121-
_LIBCPP_ASSERT_UNCATEGORIZED(
121+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
122122
!empty(), "Precondition `!empty()` not satisfied. `.front()` called on an empty view.");
123123
return *ranges::begin(__derived());
124124
}
@@ -127,15 +127,17 @@ class view_interface {
127127
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) back()
128128
requires bidirectional_range<_D2> && common_range<_D2>
129129
{
130-
_LIBCPP_ASSERT_UNCATEGORIZED(!empty(), "Precondition `!empty()` not satisfied. `.back()` called on an empty view.");
130+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
131+
!empty(), "Precondition `!empty()` not satisfied. `.back()` called on an empty view.");
131132
return *ranges::prev(ranges::end(__derived()));
132133
}
133134

134135
template <class _D2 = _Derived>
135136
_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) back() const
136137
requires bidirectional_range<const _D2> && common_range<const _D2>
137138
{
138-
_LIBCPP_ASSERT_UNCATEGORIZED(!empty(), "Precondition `!empty()` not satisfied. `.back()` called on an empty view.");
139+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
140+
!empty(), "Precondition `!empty()` not satisfied. `.back()` called on an empty view.");
139141
return *ranges::prev(ranges::end(__derived()));
140142
}
141143

libcxx/include/__utility/is_pointer_in_range.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ template <class _Tp, class _Up, __enable_if_t<__is_less_than_comparable<const _T
3535
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_SANITIZE("address") bool __is_pointer_in_range(
3636
const _Tp* __begin, const _Tp* __end, const _Up* __ptr) {
3737
if (__libcpp_is_constant_evaluated()) {
38-
_LIBCPP_ASSERT_UNCATEGORIZED(__builtin_constant_p(__begin <= __end), "__begin and __end do not form a range");
38+
_LIBCPP_ASSERT_VALID_INPUT_RANGE(__builtin_constant_p(__begin <= __end), "__begin and __end do not form a range");
3939

4040
// If this is not a constant during constant evaluation we know that __ptr is not part of the allocation where
4141
// [__begin, __end) is.

libcxx/include/experimental/__simd/vec_ext.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ struct __simd_storage<_Tp, simd_abi::__vec_ext<_Np>> {
3838
_Tp __data __attribute__((__vector_size__(std::__bit_ceil((sizeof(_Tp) * _Np)))));
3939

4040
_LIBCPP_HIDE_FROM_ABI _Tp __get(size_t __idx) const noexcept {
41-
_LIBCPP_ASSERT_UNCATEGORIZED(__idx >= 0 && __idx < _Np, "Index is out of bounds");
41+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__idx >= 0 && __idx < _Np, "Index is out of bounds");
4242
return __data[__idx];
4343
}
4444
_LIBCPP_HIDE_FROM_ABI void __set(size_t __idx, _Tp __v) noexcept {
45-
_LIBCPP_ASSERT_UNCATEGORIZED(__idx >= 0 && __idx < _Np, "Index is out of bounds");
45+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__idx >= 0 && __idx < _Np, "Index is out of bounds");
4646
__data[__idx] = __v;
4747
}
4848
};

libcxx/src/support/ibm/xlocale_zos.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ locale_t uselocale(locale_t newloc) {
103103
tokenized.push_back(s);
104104
}
105105

106-
_LIBCPP_ASSERT_UNCATEGORIZED(tokenized.size() >= _NCAT, "locale-name list is too short");
106+
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(tokenized.size() >= _NCAT, "locale-name list is too short");
107107

108108
previous_loc->lc_collate = tokenized[LC_COLLATE];
109109
previous_loc->lc_ctype = tokenized[LC_CTYPE];

libcxx/test/libcxx/algorithms/alg.sorting/assert.min.max.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// REQUIRES: has-unix-headers
1212
// UNSUPPORTED: c++03, c++11, c++14, c++17
13-
// REQUIRES: libcpp-hardening-mode={{extensive|debug}}
13+
// UNSUPPORTED: libcpp-hardening-mode=none
1414
// XFAIL: availability-verbose_abort-missing
1515

1616
#include <algorithm>

0 commit comments

Comments
 (0)