Commit df2c771e by Abseil Team Committed by Copybara-Service

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
parent 1ac7f340
...@@ -501,11 +501,19 @@ using swap_internal::StdSwapIsUnconstrained; ...@@ -501,11 +501,19 @@ using swap_internal::StdSwapIsUnconstrained;
// //
// TODO(b/275003464): remove the opt-out once the bug is fixed. // 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 // According to https://github.com/abseil/abseil-cpp/issues/1479, this does not
// work with NVCC either. // work with NVCC either.
#if ABSL_HAVE_BUILTIN(__is_trivially_relocatable) && \ #if ABSL_HAVE_BUILTIN(__is_trivially_relocatable) && \
!(defined(__clang__) && (defined(_WIN32) || defined(_WIN64))) && \ !(defined(__clang__) && (defined(_WIN32) || defined(_WIN64))) && \
!defined(__NVCC__) !(defined(__APPLE__)) && !defined(__NVCC__)
template <class T> template <class T>
struct is_trivially_relocatable struct is_trivially_relocatable
: std::integral_constant<bool, __is_trivially_relocatable(T)> {}; : std::integral_constant<bool, __is_trivially_relocatable(T)> {};
......
...@@ -792,9 +792,12 @@ TEST(TriviallyRelocatable, UserProvidedDestructor) { ...@@ -792,9 +792,12 @@ TEST(TriviallyRelocatable, UserProvidedDestructor) {
// TODO(b/275003464): remove the opt-out for Clang on Windows once // TODO(b/275003464): remove the opt-out for Clang on Windows once
// __is_trivially_relocatable is used there again. // __is_trivially_relocatable is used there again.
#if defined(ABSL_HAVE_ATTRIBUTE_TRIVIAL_ABI) && \ // TODO(b/324278148): remove the opt-out for Apple once
ABSL_HAVE_BUILTIN(__is_trivially_relocatable) && \ // __is_trivially_relocatable is fixed there.
!(defined(__clang__) && (defined(_WIN32) || defined(_WIN64))) #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 // A type marked with the "trivial ABI" attribute is trivially relocatable even
// if it has user-provided move/copy constructors and a user-provided // if it has user-provided move/copy constructors and a user-provided
// destructor. // destructor.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment