Skip to content

Commit 61c221c

Browse files
Add [[clang::lifetimebound]] to numerous functions in libc++ include headers
1 parent 733c4c0 commit 61c221c

37 files changed

+538
-538
lines changed

libcxx/include/__bit_reference

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,10 +609,10 @@ struct __bit_array {
609609
std::__construct_at(__word_ + __i, 0);
610610
}
611611
}
612-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() {
612+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() _LIBCPP_LIFETIMEBOUND {
613613
return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]), 0);
614614
}
615-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator end() {
615+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator end() _LIBCPP_LIFETIMEBOUND {
616616
return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]) + __size_ / __bits_per_word,
617617
static_cast<unsigned>(__size_ % __bits_per_word));
618618
}
@@ -905,7 +905,7 @@ public:
905905
return (__x.__seg_ - __y.__seg_) * __bits_per_word + __x.__ctz_ - __y.__ctz_;
906906
}
907907

908-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator[](difference_type __n) const {
908+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator[](difference_type __n) const _LIBCPP_LIFETIMEBOUND {
909909
return *(*this + __n);
910910
}
911911

libcxx/include/__chrono/tzdb_list.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ class _LIBCPP_AVAILABILITY_TZDB tzdb_list {
5353

5454
using const_iterator = forward_list<tzdb>::const_iterator;
5555

56-
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI const tzdb& front() const noexcept { return __front(); }
56+
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI const tzdb& front() const noexcept _LIBCPP_LIFETIMEBOUND { return __front(); }
5757

58-
_LIBCPP_HIDE_FROM_ABI const_iterator erase_after(const_iterator __p) { return __erase_after(__p); }
58+
_LIBCPP_HIDE_FROM_ABI const_iterator erase_after(const_iterator __p) _LIBCPP_LIFETIMEBOUND { return __erase_after(__p); }
5959

60-
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator begin() const noexcept { return __begin(); }
61-
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator end() const noexcept { return __end(); }
60+
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator begin() const noexcept _LIBCPP_LIFETIMEBOUND { return __begin(); }
61+
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator end() const noexcept _LIBCPP_LIFETIMEBOUND { return __end(); }
6262

63-
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const noexcept { return __cbegin(); }
64-
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator cend() const noexcept { return __cend(); }
63+
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const noexcept _LIBCPP_LIFETIMEBOUND { return __cbegin(); }
64+
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator cend() const noexcept _LIBCPP_LIFETIMEBOUND { return __cend(); }
6565

6666
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI __impl& __implementation() { return *__impl_; }
6767

libcxx/include/__expected/expected.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,15 +714,15 @@ class expected : private __expected_base<_Tp, _Err> {
714714

715715
template <class... _Args>
716716
requires is_nothrow_constructible_v<_Tp, _Args...>
717-
_LIBCPP_HIDE_FROM_ABI constexpr _Tp& emplace(_Args&&... __args) noexcept {
717+
_LIBCPP_HIDE_FROM_ABI constexpr _Tp& emplace(_Args&&... __args) noexcept _LIBCPP_LIFETIMEBOUND {
718718
this->__destroy();
719719
this->__construct(in_place, std::forward<_Args>(__args)...);
720720
return this->__val();
721721
}
722722

723723
template <class _Up, class... _Args>
724724
requires is_nothrow_constructible_v<_Tp, initializer_list<_Up>&, _Args...>
725-
_LIBCPP_HIDE_FROM_ABI constexpr _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) noexcept {
725+
_LIBCPP_HIDE_FROM_ABI constexpr _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) noexcept _LIBCPP_LIFETIMEBOUND {
726726
this->__destroy();
727727
this->__construct(in_place, __il, std::forward<_Args>(__args)...);
728728
return this->__val();

libcxx/include/__format/format_parse_context.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ class _LIBCPP_TEMPLATE_VIS basic_format_parse_context {
4141
basic_format_parse_context(const basic_format_parse_context&) = delete;
4242
basic_format_parse_context& operator=(const basic_format_parse_context&) = delete;
4343

44-
_LIBCPP_HIDE_FROM_ABI constexpr const_iterator begin() const noexcept { return __begin_; }
45-
_LIBCPP_HIDE_FROM_ABI constexpr const_iterator end() const noexcept { return __end_; }
44+
_LIBCPP_HIDE_FROM_ABI constexpr const_iterator begin() const noexcept _LIBCPP_LIFETIMEBOUND { return __begin_; }
45+
_LIBCPP_HIDE_FROM_ABI constexpr const_iterator end() const noexcept _LIBCPP_LIFETIMEBOUND { return __end_; }
4646
_LIBCPP_HIDE_FROM_ABI constexpr void advance_to(const_iterator __it) { __begin_ = __it; }
4747

4848
_LIBCPP_HIDE_FROM_ABI constexpr size_t next_arg_id() {

libcxx/include/__format/formatter_floating_point.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ class _LIBCPP_TEMPLATE_VIS __float_buffer {
183183
_LIBCPP_HIDE_FROM_ABI __float_buffer(const __float_buffer&) = delete;
184184
_LIBCPP_HIDE_FROM_ABI __float_buffer& operator=(const __float_buffer&) = delete;
185185

186-
_LIBCPP_HIDE_FROM_ABI char* begin() const { return __begin_; }
187-
_LIBCPP_HIDE_FROM_ABI char* end() const { return __begin_ + __size_; }
186+
_LIBCPP_HIDE_FROM_ABI char* begin() const _LIBCPP_LIFETIMEBOUND { return __begin_; }
187+
_LIBCPP_HIDE_FROM_ABI char* end() const _LIBCPP_LIFETIMEBOUND { return __begin_ + __size_; }
188188

189189
_LIBCPP_HIDE_FROM_ABI int __precision() const { return __precision_; }
190190
_LIBCPP_HIDE_FROM_ABI int __num_trailing_zeros() const { return __num_trailing_zeros_; }

libcxx/include/__hash_table

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -891,10 +891,10 @@ public:
891891

892892
_LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __bucket_list_.get_deleter().size(); }
893893

894-
_LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT;
895-
_LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT;
896-
_LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT;
897-
_LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT;
894+
_LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT _LIBCPP_LIFETIMEBOUND;
895+
_LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT _LIBCPP_LIFETIMEBOUND;
896+
_LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND;
897+
_LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND;
898898

899899
template <class _Key>
900900
_LIBCPP_HIDE_FROM_ABI size_type bucket(const _Key& __k) const {
@@ -904,15 +904,15 @@ public:
904904
}
905905

906906
template <class _Key>
907-
_LIBCPP_HIDE_FROM_ABI iterator find(const _Key& __x);
907+
_LIBCPP_HIDE_FROM_ABI iterator find(const _Key& __x) _LIBCPP_LIFETIMEBOUND;
908908
template <class _Key>
909-
_LIBCPP_HIDE_FROM_ABI const_iterator find(const _Key& __x) const;
909+
_LIBCPP_HIDE_FROM_ABI const_iterator find(const _Key& __x) const _LIBCPP_LIFETIMEBOUND;
910910

911911
typedef __hash_node_destructor<__node_allocator> _Dp;
912912
typedef unique_ptr<__node, _Dp> __node_holder;
913913

914-
_LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p);
915-
_LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last);
914+
_LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) _LIBCPP_LIFETIMEBOUND;
915+
_LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last) _LIBCPP_LIFETIMEBOUND;
916916
template <class _Key>
917917
_LIBCPP_HIDE_FROM_ABI size_type __erase_unique(const _Key& __k);
918918
template <class _Key>

libcxx/include/__iterator/bounded_iter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ struct __bounded_iter {
118118
return std::__to_address(__current_);
119119
}
120120

121-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator[](difference_type __n) const _NOEXCEPT {
121+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator[](difference_type __n) const _NOEXCEPT _LIBCPP_LIFETIMEBOUND {
122122
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
123123
__n >= __begin_ - __current_, "__bounded_iter::operator[]: Attempt to index an iterator past the start");
124124
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(

libcxx/include/__iterator/move_iterator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class _LIBCPP_TEMPLATE_VIS move_iterator
140140
_LIBCPP_HIDE_FROM_ABI constexpr _Iter base() && { return std::move(__current_); }
141141

142142
_LIBCPP_HIDE_FROM_ABI constexpr reference operator*() const { return ranges::iter_move(__current_); }
143-
_LIBCPP_HIDE_FROM_ABI constexpr reference operator[](difference_type __n) const {
143+
_LIBCPP_HIDE_FROM_ABI constexpr reference operator[](difference_type __n) const _LIBCPP_LIFETIMEBOUND {
144144
return ranges::iter_move(__current_ + __n);
145145
}
146146

@@ -174,7 +174,7 @@ class _LIBCPP_TEMPLATE_VIS move_iterator
174174
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator*() const {
175175
return static_cast<reference>(*__current_);
176176
}
177-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](difference_type __n) const {
177+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](difference_type __n) const _LIBCPP_LIFETIMEBOUND {
178178
return static_cast<reference>(__current_[__n]);
179179
}
180180

libcxx/include/__iterator/reverse_iterator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class _LIBCPP_TEMPLATE_VIS reverse_iterator
180180
current += __n;
181181
return *this;
182182
}
183-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](difference_type __n) const {
183+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](difference_type __n) const _LIBCPP_LIFETIMEBOUND {
184184
return *(*this + __n);
185185
}
186186

libcxx/include/__iterator/wrap_iter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class __wrap_iter {
8787
*this += -__n;
8888
return *this;
8989
}
90-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator[](difference_type __n) const _NOEXCEPT {
90+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator[](difference_type __n) const _NOEXCEPT _LIBCPP_LIFETIMEBOUND {
9191
return __i_[__n];
9292
}
9393

0 commit comments

Comments
 (0)