diff options
author | Abseil Team <absl-team@google.com> | 2024-02-09 14:08:46 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-02-09 14:09:28 -0800 |
commit | df2c771ec596b385448117f237ee70be35efe4ce (patch) | |
tree | b3713e0404ec08e4c5c1128e0a6315d8796e9c1f | |
parent | 1ac7f340105c75e447f5f98b77b71e4df2125153 (diff) |
On Apple, implement absl::is_trivially_relocatable with the fallback.
The Apple implementation gives false positives starting with
Xcode 15.
PiperOrigin-RevId: 605726702
Change-Id: I2e5e574eca08071d24e97304f005cf9c78230913
-rw-r--r-- | absl/meta/type_traits.h | 10 | ||||
-rw-r--r-- | absl/meta/type_traits_test.cc | 9 |
2 files changed, 15 insertions, 4 deletions
diff --git a/absl/meta/type_traits.h b/absl/meta/type_traits.h index cf71164b..a456ae4f 100644 --- a/absl/meta/type_traits.h +++ b/absl/meta/type_traits.h @@ -501,11 +501,19 @@ using swap_internal::StdSwapIsUnconstrained; // // TODO(b/275003464): remove the opt-out once the bug is fixed. // +// Starting with Xcode 15, the Apple compiler will falsely say a type +// with a user-provided move constructor is trivially relocatable +// (b/324278148). We will opt out without a version check, due to +// the fluidity of Apple versions. +// +// TODO(b/324278148): If all versions we use have the bug fixed, then +// remove the condition. +// // According to https://github.com/abseil/abseil-cpp/issues/1479, this does not // work with NVCC either. #if ABSL_HAVE_BUILTIN(__is_trivially_relocatable) && \ !(defined(__clang__) && (defined(_WIN32) || defined(_WIN64))) && \ - !defined(__NVCC__) + !(defined(__APPLE__)) && !defined(__NVCC__) template <class T> struct is_trivially_relocatable : std::integral_constant<bool, __is_trivially_relocatable(T)> {}; diff --git a/absl/meta/type_traits_test.cc b/absl/meta/type_traits_test.cc index 7412f33d..8f926901 100644 --- a/absl/meta/type_traits_test.cc +++ b/absl/meta/type_traits_test.cc @@ -792,9 +792,12 @@ TEST(TriviallyRelocatable, UserProvidedDestructor) { // TODO(b/275003464): remove the opt-out for Clang on Windows once // __is_trivially_relocatable is used there again. -#if defined(ABSL_HAVE_ATTRIBUTE_TRIVIAL_ABI) && \ - ABSL_HAVE_BUILTIN(__is_trivially_relocatable) && \ - !(defined(__clang__) && (defined(_WIN32) || defined(_WIN64))) +// TODO(b/324278148): remove the opt-out for Apple once +// __is_trivially_relocatable is fixed there. +#if defined(ABSL_HAVE_ATTRIBUTE_TRIVIAL_ABI) && \ + ABSL_HAVE_BUILTIN(__is_trivially_relocatable) && \ + !(defined(__clang__) && (defined(_WIN32) || defined(_WIN64))) && \ + !defined(__APPLE__) // A type marked with the "trivial ABI" attribute is trivially relocatable even // if it has user-provided move/copy constructors and a user-provided // destructor. |