Skip to content

Commit 1bdd76e

Browse files
Add [[clang::lifetimebound]] to numerous functions in libc++ include headers
1 parent f35a14d commit 1bdd76e

Some content is hidden

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

52 files changed

+628
-628
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/__filesystem/directory_iterator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ operator!=(const directory_iterator& __lhs, const directory_iterator& __rhs) noe
124124
}
125125

126126
// enable directory_iterator range-based for statements
127-
inline _LIBCPP_HIDE_FROM_ABI directory_iterator begin(directory_iterator __iter) noexcept { return __iter; }
127+
inline _LIBCPP_HIDE_FROM_ABI directory_iterator begin(directory_iterator __iter) noexcept _LIBCPP_LIFETIMEBOUND { return __iter; }
128128

129-
inline _LIBCPP_HIDE_FROM_ABI directory_iterator end(directory_iterator) noexcept { return directory_iterator(); }
129+
inline _LIBCPP_HIDE_FROM_ABI directory_iterator end(directory_iterator) noexcept _LIBCPP_LIFETIMEBOUND { return directory_iterator(); }
130130

131131
_LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP
132132

libcxx/include/__filesystem/recursive_directory_iterator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@ operator!=(const recursive_directory_iterator& __lhs, const recursive_directory_
133133
return !(__lhs == __rhs);
134134
}
135135
// enable recursive_directory_iterator range-based for statements
136-
inline _LIBCPP_HIDE_FROM_ABI recursive_directory_iterator begin(recursive_directory_iterator __iter) noexcept {
136+
inline _LIBCPP_HIDE_FROM_ABI recursive_directory_iterator begin(recursive_directory_iterator __iter) noexcept _LIBCPP_LIFETIMEBOUND {
137137
return __iter;
138138
}
139139

140-
inline _LIBCPP_HIDE_FROM_ABI recursive_directory_iterator end(recursive_directory_iterator) noexcept {
140+
inline _LIBCPP_HIDE_FROM_ABI recursive_directory_iterator end(recursive_directory_iterator) noexcept _LIBCPP_LIFETIMEBOUND {
141141
return recursive_directory_iterator();
142142
}
143143

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: 12 additions & 12 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>
@@ -958,25 +958,25 @@ public:
958958
max_load_factor() = std::max(__mlf, load_factor());
959959
}
960960

961-
_LIBCPP_HIDE_FROM_ABI local_iterator begin(size_type __n) {
961+
_LIBCPP_HIDE_FROM_ABI local_iterator begin(size_type __n) _LIBCPP_LIFETIMEBOUND {
962962
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
963963
__n < bucket_count(), "unordered container::begin(n) called with n >= bucket_count()");
964964
return local_iterator(__bucket_list_[__n], __n, bucket_count());
965965
}
966966

967-
_LIBCPP_HIDE_FROM_ABI local_iterator end(size_type __n) {
967+
_LIBCPP_HIDE_FROM_ABI local_iterator end(size_type __n) _LIBCPP_LIFETIMEBOUND {
968968
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
969969
__n < bucket_count(), "unordered container::end(n) called with n >= bucket_count()");
970970
return local_iterator(nullptr, __n, bucket_count());
971971
}
972972

973-
_LIBCPP_HIDE_FROM_ABI const_local_iterator cbegin(size_type __n) const {
973+
_LIBCPP_HIDE_FROM_ABI const_local_iterator cbegin(size_type __n) const _LIBCPP_LIFETIMEBOUND {
974974
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
975975
__n < bucket_count(), "unordered container::cbegin(n) called with n >= bucket_count()");
976976
return const_local_iterator(__bucket_list_[__n], __n, bucket_count());
977977
}
978978

979-
_LIBCPP_HIDE_FROM_ABI const_local_iterator cend(size_type __n) const {
979+
_LIBCPP_HIDE_FROM_ABI const_local_iterator cend(size_type __n) const _LIBCPP_LIFETIMEBOUND {
980980
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
981981
__n < bucket_count(), "unordered container::cend(n) called with n >= bucket_count()");
982982
return const_local_iterator(nullptr, __n, bucket_count());

libcxx/include/__iterator/access.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,22 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto cend(const _Cp& __c) noexcept(noexcept(std:
6969
#else // defined(_LIBCPP_CXX03_LANG)
7070

7171
template <class _Cp>
72-
_LIBCPP_HIDE_FROM_ABI typename _Cp::iterator begin(_Cp& __c) {
72+
_LIBCPP_HIDE_FROM_ABI typename _Cp::iterator begin(_Cp& __c) _LIBCPP_LIFETIMEBOUND {
7373
return __c.begin();
7474
}
7575

7676
template <class _Cp>
77-
_LIBCPP_HIDE_FROM_ABI typename _Cp::const_iterator begin(const _Cp& __c) {
77+
_LIBCPP_HIDE_FROM_ABI typename _Cp::const_iterator begin(const _Cp& __c) _LIBCPP_LIFETIMEBOUND {
7878
return __c.begin();
7979
}
8080

8181
template <class _Cp>
82-
_LIBCPP_HIDE_FROM_ABI typename _Cp::iterator end(_Cp& __c) {
82+
_LIBCPP_HIDE_FROM_ABI typename _Cp::iterator end(_Cp& __c) _LIBCPP_LIFETIMEBOUND {
8383
return __c.end();
8484
}
8585

8686
template <class _Cp>
87-
_LIBCPP_HIDE_FROM_ABI typename _Cp::const_iterator end(const _Cp& __c) {
87+
_LIBCPP_HIDE_FROM_ABI typename _Cp::const_iterator end(const _Cp& __c) _LIBCPP_LIFETIMEBOUND {
8888
return __c.end();
8989
}
9090

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(

0 commit comments

Comments
 (0)