Skip to content

Commit ec4005f

Browse files
committed
[libc++][hardening] Mark the remaining stray assertions as uncategorized
This avoids enabling them unconditionally in all hardening modes. Reviewed By: #libc, Mordante Differential Revision: https://reviews.llvm.org/D158970
1 parent 5d49c9c commit ec4005f

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

libcxx/include/__algorithm/three_way_comp_ref_type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct __debug_three_way_comp {
5050
__expected = _Order::greater;
5151
if (__o == _Order::greater)
5252
__expected = _Order::less;
53-
_LIBCPP_ASSERT(__comp_(__l, __r) == __expected, "Comparator does not induce a strict weak ordering");
53+
_LIBCPP_ASSERT_UNCATEGORIZED(__comp_(__l, __r) == __expected, "Comparator does not induce a strict weak ordering");
5454
(void)__l;
5555
(void)__r;
5656
}

libcxx/include/__mdspan/layout_left.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ class layout_left::mapping {
137137
// return a value exceeding required_span_size(), which is used to know how large an allocation one needs
138138
// Thus, this is a canonical point in multi-dimensional data structures to make invalid element access checks
139139
// However, mdspan does check this on its own, so for now we avoid double checking in hardened mode
140-
_LIBCPP_ASSERT(__mdspan_detail::__is_multidimensional_index_in(__extents_, __idx...),
141-
"layout_left::mapping: out of bounds indexing");
140+
_LIBCPP_ASSERT_UNCATEGORIZED(__mdspan_detail::__is_multidimensional_index_in(__extents_, __idx...),
141+
"layout_left::mapping: out of bounds indexing");
142142
array<index_type, extents_type::rank()> __idx_a{static_cast<index_type>(__idx)...};
143143
return [&]<size_t... _Pos>(index_sequence<_Pos...>) {
144144
index_type __res = 0;

libcxx/include/__mdspan/layout_right.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ class layout_right::mapping {
136136
// return a value exceeding required_span_size(), which is used to know how large an allocation one needs
137137
// Thus, this is a canonical point in multi-dimensional data structures to make invalid element access checks
138138
// However, mdspan does check this on its own, so for now we avoid double checking in hardened mode
139-
_LIBCPP_ASSERT(__mdspan_detail::__is_multidimensional_index_in(__extents_, __idx...),
140-
"layout_right::mapping: out of bounds indexing");
139+
_LIBCPP_ASSERT_UNCATEGORIZED(__mdspan_detail::__is_multidimensional_index_in(__extents_, __idx...),
140+
"layout_right::mapping: out of bounds indexing");
141141
return [&]<size_t... _Pos>(index_sequence<_Pos...>) {
142142
index_type __res = 0;
143143
((__res = static_cast<index_type>(__idx) + __extents_.extent(_Pos) * __res), ...);

libcxx/include/__ranges/repeat_view.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ class repeat_view : public view_interface<repeat_view<_Tp, _Bound>> {
8282
requires copy_constructible<_Tp>
8383
: __value_(in_place, __value), __bound_(__bound_sentinel) {
8484
if constexpr (!same_as<_Bound, unreachable_sentinel_t>)
85-
_LIBCPP_ASSERT(__bound_ >= 0, "The value of bound must be greater than or equal to 0");
85+
_LIBCPP_ASSERT_UNCATEGORIZED(__bound_ >= 0, "The value of bound must be greater than or equal to 0");
8686
}
8787

8888
_LIBCPP_HIDE_FROM_ABI constexpr explicit repeat_view(_Tp&& __value, _Bound __bound_sentinel = _Bound())
8989
: __value_(in_place, std::move(__value)), __bound_(__bound_sentinel) {
9090
if constexpr (!same_as<_Bound, unreachable_sentinel_t>)
91-
_LIBCPP_ASSERT(__bound_ >= 0, "The value of bound must be greater than or equal to 0");
91+
_LIBCPP_ASSERT_UNCATEGORIZED(__bound_ >= 0, "The value of bound must be greater than or equal to 0");
9292
}
9393

9494
template <class... _TpArgs, class... _BoundArgs>
@@ -98,7 +98,7 @@ class repeat_view : public view_interface<repeat_view<_Tp, _Bound>> {
9898
: __value_(in_place, std::make_from_tuple<_Tp>(std::move(__value_args))),
9999
__bound_(std::make_from_tuple<_Bound>(std::move(__bound_args))) {
100100
if constexpr (!same_as<_Bound, unreachable_sentinel_t>)
101-
_LIBCPP_ASSERT(
101+
_LIBCPP_ASSERT_UNCATEGORIZED(
102102
__bound_ >= 0, "The behavior is undefined if Bound is not unreachable_sentinel_t and bound is negative");
103103
}
104104

@@ -161,7 +161,7 @@ class repeat_view<_Tp, _Bound>::__iterator {
161161

162162
_LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator--() {
163163
if constexpr (!same_as<_Bound, unreachable_sentinel_t>)
164-
_LIBCPP_ASSERT(__current_ > 0, "The value of bound must be greater than or equal to 0");
164+
_LIBCPP_ASSERT_UNCATEGORIZED(__current_ > 0, "The value of bound must be greater than or equal to 0");
165165
--__current_;
166166
return *this;
167167
}
@@ -174,14 +174,14 @@ class repeat_view<_Tp, _Bound>::__iterator {
174174

175175
_LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator+=(difference_type __n) {
176176
if constexpr (!same_as<_Bound, unreachable_sentinel_t>)
177-
_LIBCPP_ASSERT(__current_ + __n >= 0, "The value of bound must be greater than or equal to 0");
177+
_LIBCPP_ASSERT_UNCATEGORIZED(__current_ + __n >= 0, "The value of bound must be greater than or equal to 0");
178178
__current_ += __n;
179179
return *this;
180180
}
181181

182182
_LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator-=(difference_type __n) {
183183
if constexpr (!same_as<_Bound, unreachable_sentinel_t>)
184-
_LIBCPP_ASSERT(__current_ - __n >= 0, "The value of bound must be greater than or equal to 0");
184+
_LIBCPP_ASSERT_UNCATEGORIZED(__current_ - __n >= 0, "The value of bound must be greater than or equal to 0");
185185
__current_ -= __n;
186186
return *this;
187187
}

libcxx/src/filesystem/posix_compat.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,8 @@ inline int statvfs(const wchar_t *p, StatVFS *buf) {
322322

323323
inline wchar_t* getcwd([[maybe_unused]] wchar_t* in_buf, [[maybe_unused]] size_t in_size) {
324324
// Only expected to be used with us allocating the buffer.
325-
_LIBCPP_ASSERT(in_buf == nullptr, "Windows getcwd() assumes in_buf==nullptr");
326-
_LIBCPP_ASSERT(in_size == 0, "Windows getcwd() assumes in_size==0");
325+
_LIBCPP_ASSERT_UNCATEGORIZED(in_buf == nullptr, "Windows getcwd() assumes in_buf==nullptr");
326+
_LIBCPP_ASSERT_UNCATEGORIZED(in_size == 0, "Windows getcwd() assumes in_size==0");
327327

328328
size_t buff_size = MAX_PATH + 10;
329329
std::unique_ptr<wchar_t, decltype(&::free)> buff(static_cast<wchar_t*>(malloc(buff_size * sizeof(wchar_t))), &::free);

0 commit comments

Comments
 (0)