From ec33a42ca3ad1db3c15cd724f22bace867ba8ab2 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Wed, 9 Oct 2024 08:22:11 -0700 Subject: [PATCH 1/2] Add missing '__to_address' calls --- libcxx/include/vector | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libcxx/include/vector b/libcxx/include/vector index 90ca2d21410817..524567a4295682 100644 --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -1582,7 +1582,7 @@ vector<_Tp, _Allocator>::erase(const_iterator __position) { // destroy the element at __p __alloc_traits::destroy(__alloc(), std::__to_address(__p)); // move the rest down - (void) relocate(__p + 1, this->__end_, __p); + (void) relocate(std::__to_address(__p + 1), std::__to_address(this->__end_), std::__to_address(__p)); // update the end this->__end_--; __annotate_shrink(__old_size); @@ -1647,7 +1647,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) if constexpr (is_trivially_relocatable_v<_Tp> || is_nothrow_move_constructible_v<_Tp>) { // Make space by trivially relocating everything _ConstructTransaction __tx(*this, 1); - (void) relocate(std::__to_address(__p), std::__to_address(this->__end_), __p + 1); + (void) relocate(std::__to_address(__p), std::__to_address(this->__end_), std::__to_address(__p + 1)); // construct the new element (not assign!) const_pointer __xr = pointer_traits::pointer_to(__x); if (std::__is_pointer_in_range(std::__to_address(__p), std::__to_address(__end_), std::addressof(__x))) @@ -1687,7 +1687,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) { if constexpr (is_trivially_relocatable_v<_Tp> || is_nothrow_move_constructible_v<_Tp>) { // Make space by trivially relocating everything _ConstructTransaction __tx(*this, 1); - (void) relocate(std::__to_address(__p), std::__to_address(this->__end_), __p + 1); + (void) relocate(std::__to_address(__p), std::__to_address(this->__end_), std::__to_address(__p + 1)); // construct the new element (not assign!) __alloc_traits::construct(this->__alloc(), std::__to_address(__p), std::forward(__x)); ++__tx.__pos_; @@ -1722,7 +1722,7 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) { if constexpr (is_trivially_relocatable_v<_Tp> || is_nothrow_move_constructible_v<_Tp>) { // Make space by trivially relocating everything _ConstructTransaction __tx(*this, 1); - (void) relocate(std::__to_address(__p), std::__to_address(this->__end_), __p + 1); + (void) relocate(std::__to_address(__p), std::__to_address(this->__end_), std::__to_address(__p + 1)); // construct the new element __alloc_traits::construct(this->__alloc(), std::__to_address(__p), std::forward<_Args>(__args)...); ++__tx.__pos_; From 13b22de3d9b06a7e7b321ec97b68d408daff9fab Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Wed, 9 Oct 2024 08:22:45 -0700 Subject: [PATCH 2/2] Add internal includes so module build is correct --- libcxx/include/__algorithm/swap_ranges.h | 5 +++++ libcxx/include/__memory/uninitialized_algorithms.h | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libcxx/include/__algorithm/swap_ranges.h b/libcxx/include/__algorithm/swap_ranges.h index 39d86a15cf9542..e1a0ee0ccbd63d 100644 --- a/libcxx/include/__algorithm/swap_ranges.h +++ b/libcxx/include/__algorithm/swap_ranges.h @@ -11,6 +11,11 @@ #include <__algorithm/iterator_operations.h> #include <__config> +#include <__cstddef/byte.h> +#include <__cstddef/size_t.h> +#include <__iterator/iterator_traits.h> +#include <__type_traits/is_same.h> +#include <__type_traits/is_trivially_relocatable.h> #include <__utility/move.h> #include <__utility/pair.h> diff --git a/libcxx/include/__memory/uninitialized_algorithms.h b/libcxx/include/__memory/uninitialized_algorithms.h index d64226056781eb..c9446d889bbf0d 100644 --- a/libcxx/include/__memory/uninitialized_algorithms.h +++ b/libcxx/include/__memory/uninitialized_algorithms.h @@ -15,6 +15,7 @@ #include <__algorithm/unwrap_iter.h> #include <__algorithm/unwrap_range.h> #include <__config> +#include <__functional/operations.h> #include <__iterator/iterator_traits.h> #include <__iterator/reverse_iterator.h> #include <__memory/addressof.h> @@ -27,6 +28,7 @@ #include <__type_traits/extent.h> #include <__type_traits/is_array.h> #include <__type_traits/is_constant_evaluated.h> +#include <__type_traits/is_nothrow_constructible.h> #include <__type_traits/is_trivially_assignable.h> #include <__type_traits/is_trivially_constructible.h> #include <__type_traits/is_trivially_relocatable.h> @@ -37,10 +39,9 @@ #include <__utility/exception_guard.h> #include <__utility/move.h> #include <__utility/pair.h> +#include <__utility/unreachable.h> #include -#include - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif