Skip to content

Commit a732f43

Browse files
Fix whitespace, add a couple of tests for [[clang::lifetimebound]] annotations in libc++, and avoid erroring on lifetimebound warnings in libcxx test code
1 parent 89e7175 commit a732f43

File tree

26 files changed

+485
-176
lines changed

26 files changed

+485
-176
lines changed

libcxx/include/__chrono/tzdb_list.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,16 @@ class _LIBCPP_AVAILABILITY_TZDB tzdb_list {
5555

5656
[[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) _LIBCPP_LIFETIMEBOUND { return __erase_after(__p); }
58+
_LIBCPP_HIDE_FROM_ABI const_iterator erase_after(const_iterator __p) _LIBCPP_LIFETIMEBOUND {
59+
return __erase_after(__p);
60+
}
5961

6062
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator begin() const noexcept _LIBCPP_LIFETIMEBOUND { return __begin(); }
6163
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator end() const noexcept _LIBCPP_LIFETIMEBOUND { return __end(); }
6264

63-
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const noexcept _LIBCPP_LIFETIMEBOUND { return __cbegin(); }
65+
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const noexcept _LIBCPP_LIFETIMEBOUND {
66+
return __cbegin();
67+
}
6468
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator cend() const noexcept _LIBCPP_LIFETIMEBOUND { return __cend(); }
6569

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

libcxx/include/__expected/expected.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,8 @@ class expected : private __expected_base<_Tp, _Err> {
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 _LIBCPP_LIFETIMEBOUND {
725+
_LIBCPP_HIDE_FROM_ABI constexpr _Tp&
726+
emplace(initializer_list<_Up> __il, _Args&&... __args) noexcept _LIBCPP_LIFETIMEBOUND {
726727
this->__destroy();
727728
this->__construct(in_place, __il, std::forward<_Args>(__args)...);
728729
return this->__val();

libcxx/include/__mdspan/extents.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ template <class _Tp, size_t _Size>
7979
struct __possibly_empty_array {
8080
_Tp __vals_[_Size];
8181
_LIBCPP_HIDE_FROM_ABI constexpr _Tp& operator[](size_t __index) _LIBCPP_LIFETIMEBOUND { return __vals_[__index]; }
82-
_LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator[](size_t __index) const _LIBCPP_LIFETIMEBOUND { return __vals_[__index]; }
82+
_LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator[](size_t __index) const _LIBCPP_LIFETIMEBOUND {
83+
return __vals_[__index];
84+
}
8385
};
8486

8587
template <class _Tp>

libcxx/include/__memory/unique_ptr.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,9 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr {
275275
return *__ptr_;
276276
}
277277
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer operator->() const _NOEXCEPT { return __ptr_; }
278-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND { return __ptr_; }
278+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND {
279+
return __ptr_;
280+
}
279281
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT { return __deleter_; }
280282
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 const deleter_type& get_deleter() const _NOEXCEPT {
281283
return __deleter_;
@@ -585,7 +587,9 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr<_Tp[], _Dp>
585587
"unique_ptr<T[]>::operator[](index): index out of range");
586588
return __ptr_[__i];
587589
}
588-
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND { return __ptr_; }
590+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer get() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND {
591+
return __ptr_;
592+
}
589593

590594
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 deleter_type& get_deleter() _NOEXCEPT { return __deleter_; }
591595

libcxx/include/__node_handle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ template <class _NodeType, class _Derived>
170170
struct __set_node_handle_specifics {
171171
typedef typename _NodeType::__node_value_type value_type;
172172

173-
_LIBCPP_HIDE_FROM_ABI value_type& value() const _LIBCPP_LIFETIMEBOUND { return static_cast<_Derived const*>(this)->__ptr_->__get_value(); }
173+
_LIBCPP_HIDE_FROM_ABI value_type& value() const _LIBCPP_LIFETIMEBOUND {
174+
return static_cast<_Derived const*>(this)->__ptr_->__get_value();
175+
}
174176
};
175177

176178
template <class _NodeType, class _Derived>

libcxx/include/__split_buffer

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,17 @@ public:
114114
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer& __end_cap() _NOEXCEPT { return __end_cap_; }
115115
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const pointer& __end_cap() const _NOEXCEPT { return __end_cap_; }
116116

117-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT _LIBCPP_LIFETIMEBOUND { return __begin_; }
118-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND { return __begin_; }
117+
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT _LIBCPP_LIFETIMEBOUND {
118+
return __begin_;
119+
}
120+
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND {
121+
return __begin_;
122+
}
119123

120124
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT _LIBCPP_LIFETIMEBOUND { return __end_; }
121-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND { return __end_; }
125+
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND {
126+
return __end_;
127+
}
122128

123129
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __destruct_at_end(__begin_); }
124130

@@ -141,9 +147,13 @@ public:
141147
}
142148

143149
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() _LIBCPP_LIFETIMEBOUND { return *__begin_; }
144-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference front() const _LIBCPP_LIFETIMEBOUND { return *__begin_; }
150+
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference front() const _LIBCPP_LIFETIMEBOUND {
151+
return *__begin_;
152+
}
145153
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() _LIBCPP_LIFETIMEBOUND { return *(__end_ - 1); }
146-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const _LIBCPP_LIFETIMEBOUND { return *(__end_ - 1); }
154+
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const _LIBCPP_LIFETIMEBOUND {
155+
return *(__end_ - 1);
156+
}
147157

148158
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n);
149159
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT;

libcxx/include/__thread/thread.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ class __thread_specific_ptr {
8282
__thread_specific_ptr& operator=(const __thread_specific_ptr&) = delete;
8383
~__thread_specific_ptr();
8484

85-
_LIBCPP_HIDE_FROM_ABI pointer get() const _LIBCPP_LIFETIMEBOUND { return static_cast<_Tp*>(__libcpp_tls_get(__key_)); }
85+
_LIBCPP_HIDE_FROM_ABI pointer get() const _LIBCPP_LIFETIMEBOUND {
86+
return static_cast<_Tp*>(__libcpp_tls_get(__key_));
87+
}
8688
_LIBCPP_HIDE_FROM_ABI pointer operator*() const { return *get(); }
8789
_LIBCPP_HIDE_FROM_ABI pointer operator->() const { return get(); }
8890
void set_pointer(pointer __p);

libcxx/include/__tree

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,9 @@ private:
962962
public:
963963
_LIBCPP_HIDE_FROM_ABI const size_type& size() const _NOEXCEPT { return __size_; }
964964
_LIBCPP_HIDE_FROM_ABI value_compare& value_comp() _NOEXCEPT _LIBCPP_LIFETIMEBOUND { return __value_comp_; }
965-
_LIBCPP_HIDE_FROM_ABI const value_compare& value_comp() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND { return __value_comp_; }
965+
_LIBCPP_HIDE_FROM_ABI const value_compare& value_comp() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND {
966+
return __value_comp_;
967+
}
966968

967969
public:
968970
_LIBCPP_HIDE_FROM_ABI __node_pointer __root() const _NOEXCEPT {
@@ -995,9 +997,13 @@ public:
995997
_LIBCPP_HIDE_FROM_ABI ~__tree();
996998

997999
_LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT _LIBCPP_LIFETIMEBOUND { return iterator(__begin_node()); }
998-
_LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND { return const_iterator(__begin_node()); }
1000+
_LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND {
1001+
return const_iterator(__begin_node());
1002+
}
9991003
_LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT _LIBCPP_LIFETIMEBOUND { return iterator(__end_node()); }
1000-
_LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND { return const_iterator(__end_node()); }
1004+
_LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND {
1005+
return const_iterator(__end_node());
1006+
}
10011007

10021008
_LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {
10031009
return std::min<size_type>(__node_traits::max_size(__node_alloc()), numeric_limits<difference_type >::max());

libcxx/include/__vector/vector.h

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -307,22 +307,32 @@ class _LIBCPP_TEMPLATE_VIS vector {
307307
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT _LIBCPP_LIFETIMEBOUND {
308308
return reverse_iterator(end());
309309
}
310-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND {
310+
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator
311+
rbegin() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND {
311312
return const_reverse_iterator(end());
312313
}
313314
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT _LIBCPP_LIFETIMEBOUND {
314315
return reverse_iterator(begin());
315316
}
316-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND {
317+
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator
318+
rend() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND {
317319
return const_reverse_iterator(begin());
318320
}
319321

320-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND { return begin(); }
321-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND { return end(); }
322-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND {
322+
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND {
323+
return begin();
324+
}
325+
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND {
326+
return end();
327+
}
328+
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator
329+
crbegin() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND {
323330
return rbegin();
324331
}
325-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND { return rend(); }
332+
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator
333+
crend() const _NOEXCEPT _LIBCPP_LIFETIMEBOUND {
334+
return rend();
335+
}
326336

327337
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT {
328338
return static_cast<size_type>(this->__end_ - this->__begin_);
@@ -337,8 +347,10 @@ class _LIBCPP_TEMPLATE_VIS vector {
337347
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n);
338348
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT;
339349

340-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference operator[](size_type __n) _NOEXCEPT _LIBCPP_LIFETIMEBOUND;
341-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __n) const _NOEXCEPT _LIBCPP_LIFETIMEBOUND;
350+
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference
351+
operator[](size_type __n) _NOEXCEPT _LIBCPP_LIFETIMEBOUND;
352+
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference
353+
operator[](size_type __n) const _NOEXCEPT _LIBCPP_LIFETIMEBOUND;
342354
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference at(size_type __n) _LIBCPP_LIFETIMEBOUND;
343355
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference at(size_type __n) const _LIBCPP_LIFETIMEBOUND;
344356

@@ -390,11 +402,14 @@ class _LIBCPP_TEMPLATE_VIS vector {
390402

391403
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_back();
392404

393-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __position, const_reference __x) _LIBCPP_LIFETIMEBOUND;
405+
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __position, const_reference __x)
406+
_LIBCPP_LIFETIMEBOUND;
394407

395-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __position, value_type&& __x) _LIBCPP_LIFETIMEBOUND;
408+
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __position, value_type&& __x)
409+
_LIBCPP_LIFETIMEBOUND;
396410
template <class... _Args>
397-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __position, _Args&&... __args) _LIBCPP_LIFETIMEBOUND;
411+
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __position, _Args&&... __args)
412+
_LIBCPP_LIFETIMEBOUND;
398413

399414
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
400415
insert(const_iterator __position, size_type __n, const_reference __x) _LIBCPP_LIFETIMEBOUND;
@@ -408,7 +423,8 @@ class _LIBCPP_TEMPLATE_VIS vector {
408423

409424
#if _LIBCPP_STD_VER >= 23
410425
template <_ContainerCompatibleRange<_Tp> _Range>
411-
_LIBCPP_HIDE_FROM_ABI constexpr iterator insert_range(const_iterator __position, _Range&& __range) _LIBCPP_LIFETIMEBOUND {
426+
_LIBCPP_HIDE_FROM_ABI constexpr iterator
427+
insert_range(const_iterator __position, _Range&& __range) _LIBCPP_LIFETIMEBOUND {
412428
if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {
413429
auto __n = static_cast<size_type>(ranges::distance(__range));
414430
return __insert_with_size(__position, ranges::begin(__range), ranges::end(__range), __n);
@@ -435,7 +451,8 @@ class _LIBCPP_TEMPLATE_VIS vector {
435451
#endif
436452

437453
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __position) _LIBCPP_LIFETIMEBOUND;
438-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last) _LIBCPP_LIFETIMEBOUND;
454+
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last)
455+
_LIBCPP_LIFETIMEBOUND;
439456

440457
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT {
441458
size_type __old_size = size();

0 commit comments

Comments
 (0)