From 1ba8ed0cd7d03ed9b70aaf32b3d8e9205ef95ef2 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Mon, 17 Jun 2024 13:09:04 +0200 Subject: [libc++] Mark more types as trivially relocatable (#89724) Co-authored-by: Louis Dionne --- libcxx/test/libcxx/transitive_includes/cxx03.csv | 1 + libcxx/test/libcxx/transitive_includes/cxx11.csv | 1 + libcxx/test/libcxx/transitive_includes/cxx14.csv | 1 + libcxx/test/libcxx/transitive_includes/cxx17.csv | 1 + libcxx/test/libcxx/transitive_includes/cxx20.csv | 1 + libcxx/test/libcxx/transitive_includes/cxx23.csv | 4 + libcxx/test/libcxx/transitive_includes/cxx26.csv | 4 + .../is_trivially_relocatable.compile.pass.cpp | 119 +++++++++++++++++++++ 8 files changed, 132 insertions(+) (limited to 'libcxx/test') diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv index b0431d9..c720a0c 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx03.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv @@ -903,6 +903,7 @@ thread type_traits thread version tuple compare tuple cstddef +tuple cstdint tuple exception tuple iosfwd tuple new diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv index 6fc8fe5..b00436a 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx11.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv @@ -910,6 +910,7 @@ thread type_traits thread version tuple compare tuple cstddef +tuple cstdint tuple exception tuple iosfwd tuple new diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv index 5771e2b..4b8c129 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx14.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv @@ -913,6 +913,7 @@ thread type_traits thread version tuple compare tuple cstddef +tuple cstdint tuple exception tuple iosfwd tuple new diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv index deba8c0..a51a7e2 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx17.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv @@ -914,6 +914,7 @@ thread type_traits thread version tuple compare tuple cstddef +tuple cstdint tuple exception tuple iosfwd tuple new diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv index b76ec5c..5280d75 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx20.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv @@ -920,6 +920,7 @@ thread type_traits thread version tuple compare tuple cstddef +tuple cstdint tuple exception tuple iosfwd tuple new diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv index bd0ba12..bfb8b5d 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx23.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv @@ -151,6 +151,7 @@ exception typeinfo exception version execution version expected cstddef +expected cstdint expected initializer_list expected new expected version @@ -484,6 +485,7 @@ regex typeinfo regex vector regex version scoped_allocator cstddef +scoped_allocator cstdint scoped_allocator limits scoped_allocator new scoped_allocator tuple @@ -640,6 +642,7 @@ thread typeinfo thread version tuple compare tuple cstddef +tuple cstdint tuple version type_traits cstddef type_traits cstdint @@ -674,6 +677,7 @@ unordered_set tuple unordered_set version utility compare utility cstddef +utility cstdint utility initializer_list utility limits utility version diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv index bd0ba12..bfb8b5d 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx26.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv @@ -151,6 +151,7 @@ exception typeinfo exception version execution version expected cstddef +expected cstdint expected initializer_list expected new expected version @@ -484,6 +485,7 @@ regex typeinfo regex vector regex version scoped_allocator cstddef +scoped_allocator cstdint scoped_allocator limits scoped_allocator new scoped_allocator tuple @@ -640,6 +642,7 @@ thread typeinfo thread version tuple compare tuple cstddef +tuple cstdint tuple version type_traits cstddef type_traits cstdint @@ -674,6 +677,7 @@ unordered_set tuple unordered_set version utility compare utility cstddef +utility cstdint utility initializer_list utility limits utility version diff --git a/libcxx/test/libcxx/type_traits/is_trivially_relocatable.compile.pass.cpp b/libcxx/test/libcxx/type_traits/is_trivially_relocatable.compile.pass.cpp index 4d1a8ad..64d2c54 100644 --- a/libcxx/test/libcxx/type_traits/is_trivially_relocatable.compile.pass.cpp +++ b/libcxx/test/libcxx/type_traits/is_trivially_relocatable.compile.pass.cpp @@ -7,11 +7,24 @@ //===----------------------------------------------------------------------===// #include <__type_traits/is_trivially_relocatable.h> +#include +#include +#include +#include #include +#include #include +#include +#include +#include #include "constexpr_char_traits.h" #include "test_allocator.h" +#include "test_macros.h" + +#ifndef TEST_HAS_NO_LOCALIZATION +# include +#endif static_assert(std::__libcpp_is_trivially_relocatable::value, ""); static_assert(std::__libcpp_is_trivially_relocatable::value, ""); @@ -44,9 +57,27 @@ static_assert(std::__libcpp_is_trivially_relocatable: #else static_assert(!std::__libcpp_is_trivially_relocatable::value, ""); #endif + +// library-internal types +// ---------------------- + +// __split_buffer +static_assert(std::__libcpp_is_trivially_relocatable >::value, ""); +static_assert(std::__libcpp_is_trivially_relocatable >::value, ""); +static_assert(!std::__libcpp_is_trivially_relocatable > >::value, ""); + // standard library types // ---------------------- +// array +static_assert(std::__libcpp_is_trivially_relocatable >::value, ""); +static_assert(std::__libcpp_is_trivially_relocatable >::value, ""); +static_assert(std::__libcpp_is_trivially_relocatable, 0> >::value, ""); + +static_assert(std::__libcpp_is_trivially_relocatable >::value, ""); +static_assert(!std::__libcpp_is_trivially_relocatable >::value, ""); +static_assert(std::__libcpp_is_trivially_relocatable, 1> >::value, ""); + // basic_string #if defined(_LIBCPP_HAS_NO_ASAN) || !defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) struct MyChar { @@ -80,6 +111,71 @@ static_assert( std::basic_string, test_allocator > >::value, ""); #endif + +// deque +static_assert(std::__libcpp_is_trivially_relocatable >::value, ""); +static_assert(std::__libcpp_is_trivially_relocatable >::value, ""); +static_assert(!std::__libcpp_is_trivially_relocatable > >::value, ""); + +// exception_ptr +#ifndef _LIBCPP_ABI_MICROSOFT // FIXME: Is this also the case on windows? +static_assert(std::__libcpp_is_trivially_relocatable::value, ""); +#endif + +// expected +#if TEST_STD_VER >= 23 +static_assert(std::__libcpp_is_trivially_relocatable >::value); +static_assert(std::__libcpp_is_trivially_relocatable, int>>::value); +static_assert(std::__libcpp_is_trivially_relocatable>>::value); +static_assert(std::__libcpp_is_trivially_relocatable, std::unique_ptr>>::value); + +static_assert(!std::__libcpp_is_trivially_relocatable>::value); +static_assert(!std::__libcpp_is_trivially_relocatable>::value); +static_assert( + !std::__libcpp_is_trivially_relocatable>::value); +#endif + +// locale +#ifndef TEST_HAS_NO_LOCALIZATION +static_assert(std::__libcpp_is_trivially_relocatable::value, ""); +#endif + +// optional +#if TEST_STD_VER >= 17 +static_assert(std::__libcpp_is_trivially_relocatable>::value, ""); +static_assert(!std::__libcpp_is_trivially_relocatable>::value, ""); +static_assert(std::__libcpp_is_trivially_relocatable>>::value, ""); +#endif // TEST_STD_VER >= 17 + +// pair +static_assert(std::__libcpp_is_trivially_relocatable >::value, ""); +static_assert(!std::__libcpp_is_trivially_relocatable >::value, ""); +static_assert(!std::__libcpp_is_trivially_relocatable >::value, ""); +static_assert(!std::__libcpp_is_trivially_relocatable >::value, + ""); +static_assert(std::__libcpp_is_trivially_relocatable, std::unique_ptr > >::value, + ""); + +// shared_ptr +static_assert(std::__libcpp_is_trivially_relocatable >::value, ""); + +// tuple +#if TEST_STD_VER >= 11 +static_assert(std::__libcpp_is_trivially_relocatable >::value, ""); + +static_assert(std::__libcpp_is_trivially_relocatable >::value, ""); +static_assert(!std::__libcpp_is_trivially_relocatable >::value, ""); +static_assert(std::__libcpp_is_trivially_relocatable > >::value, ""); + +static_assert(std::__libcpp_is_trivially_relocatable >::value, ""); +static_assert(!std::__libcpp_is_trivially_relocatable >::value, ""); +static_assert(!std::__libcpp_is_trivially_relocatable >::value, ""); +static_assert(!std::__libcpp_is_trivially_relocatable >::value, + ""); +static_assert(std::__libcpp_is_trivially_relocatable, std::unique_ptr > >::value, + ""); +#endif // TEST_STD_VER >= 11 + // unique_ptr struct NotTriviallyRelocatableDeleter { NotTriviallyRelocatableDeleter(const NotTriviallyRelocatableDeleter&); @@ -113,4 +209,27 @@ static_assert(!std::__libcpp_is_trivially_relocatable >::value, ""); +// variant +#if TEST_STD_VER >= 17 +static_assert(std::__libcpp_is_trivially_relocatable >::value, ""); +static_assert(!std::__libcpp_is_trivially_relocatable >::value, ""); +static_assert(std::__libcpp_is_trivially_relocatable > >::value, ""); + +static_assert(std::__libcpp_is_trivially_relocatable >::value, ""); +static_assert(!std::__libcpp_is_trivially_relocatable >::value, ""); +static_assert(!std::__libcpp_is_trivially_relocatable >::value, ""); +static_assert(!std::__libcpp_is_trivially_relocatable >::value, + ""); +static_assert(std::__libcpp_is_trivially_relocatable, std::unique_ptr > >::value, + ""); +#endif // TEST_STD_VER >= 17 + +// vector +static_assert(std::__libcpp_is_trivially_relocatable >::value, ""); +static_assert(std::__libcpp_is_trivially_relocatable >::value, ""); +static_assert(!std::__libcpp_is_trivially_relocatable > >::value, ""); + +// weak_ptr +static_assert(std::__libcpp_is_trivially_relocatable >::value, ""); + // TODO: Mark all the trivially relocatable STL types as such -- cgit v1.1