summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2023-01-23 10:28:34 +0100
committerPeter Varga <pvarga@inf.u-szeged.hu>2023-02-01 15:37:53 +0000
commit8b2b44128018e2df1c236be32d28dac36c90e165 (patch)
treec09f5d3a9bd108b2cff866bffb20b87ca5f2c3b7
parentf250f1157f69e57715553623c99a47c9b81850eb (diff)
downloadqtwebengine-chromium-8b2b44128018e2df1c236be32d28dac36c90e165.tar.gz
[Backport] Map the absl::is_trivially_* functions to their std impl
There's no point redefining these functions if they are supported by the compiler and the version of libstdc++. Also, some of the builtins used by the absl implementation of these functions (e.g. __has_trivial_destructor) have been deprecated in Clang 15. Original commit: https://github.com/abseil/abseil-cpp/commit/cfe27e79cfcbefb2b4479e04f80cbb299bc46965 Task-number: QTBUG-108240 Change-Id: I7373b65d84909b2e1877b78ff9058446ab5720e4 Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/455714 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r--chromium/third_party/abseil-cpp/absl/base/config.h11
-rw-r--r--chromium/third_party/abseil-cpp/absl/meta/type_traits.h23
-rw-r--r--chromium/third_party/abseil-cpp/absl/meta/type_traits_test.cc1
3 files changed, 35 insertions, 0 deletions
diff --git a/chromium/third_party/abseil-cpp/absl/base/config.h b/chromium/third_party/abseil-cpp/absl/base/config.h
index c1d0494eedd..4458987f4a6 100644
--- a/chromium/third_party/abseil-cpp/absl/base/config.h
+++ b/chromium/third_party/abseil-cpp/absl/base/config.h
@@ -208,6 +208,17 @@ static_assert(ABSL_INTERNAL_INLINE_NAMESPACE_STR[0] != 'h' ||
#define ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE 1
#endif
+// ABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE
+//
+// Checks whether `std::is_trivially_copyable<T>` is supported.
+//
+// Notes: Clang 15+ with libc++ supports these features, GCC hasn't been tested.
+#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE)
+#error ABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE cannot be directly set
+#elif defined(__clang__) && (__clang_major__ >= 15)
+#define ABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE 1
+#endif
+
// ABSL_HAVE_SOURCE_LOCATION_CURRENT
//
// Indicates whether `absl::SourceLocation::current()` will return useful
diff --git a/chromium/third_party/abseil-cpp/absl/meta/type_traits.h b/chromium/third_party/abseil-cpp/absl/meta/type_traits.h
index 75689bb658f..eb6ed91668b 100644
--- a/chromium/third_party/abseil-cpp/absl/meta/type_traits.h
+++ b/chromium/third_party/abseil-cpp/absl/meta/type_traits.h
@@ -290,8 +290,12 @@ struct is_function
// https://gcc.gnu.org/onlinedocs/gcc/Type-Traits.html#Type-Traits.
template <typename T>
struct is_trivially_destructible
+#ifdef ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE
+ : std::is_trivially_destructible<T> {
+#else
: std::integral_constant<bool, __has_trivial_destructor(T) &&
std::is_destructible<T>::value> {
+#endif
#ifdef ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE
private:
static constexpr bool compliant = std::is_trivially_destructible<T>::value ==
@@ -339,9 +343,13 @@ struct is_trivially_destructible
// Nontrivially destructible types will cause the expression to be nontrivial.
template <typename T>
struct is_trivially_default_constructible
+#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE)
+ : std::is_trivially_default_constructible<T> {
+#else
: std::integral_constant<bool, __has_trivial_constructor(T) &&
std::is_default_constructible<T>::value &&
is_trivially_destructible<T>::value> {
+#endif
#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) && \
!defined( \
ABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION)
@@ -373,10 +381,14 @@ struct is_trivially_default_constructible
// expression to be nontrivial.
template <typename T>
struct is_trivially_move_constructible
+#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE)
+ : std::is_trivially_move_constructible<T> {
+#else
: std::conditional<
std::is_object<T>::value && !std::is_array<T>::value,
type_traits_internal::IsTriviallyMoveConstructibleObject<T>,
std::is_reference<T>>::type::type {
+#endif
#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) && \
!defined( \
ABSL_META_INTERNAL_STD_CONSTRUCTION_TRAITS_DONT_CHECK_DESTRUCTION)
@@ -482,9 +494,13 @@ struct is_trivially_move_assignable
// `is_trivially_assignable<T&, const T&>`.
template <typename T>
struct is_trivially_copy_assignable
+#ifdef ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE
+ : std::is_trivially_copy_assignable<T> {
+#else
: std::integral_constant<
bool, __has_trivial_assign(typename std::remove_reference<T>::type) &&
absl::is_copy_assignable<T>::value> {
+#endif
#ifdef ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE
private:
static constexpr bool compliant =
@@ -515,6 +531,12 @@ namespace type_traits_internal {
// destructible. Arrays of trivially copyable types are trivially copyable.
//
// We expose this metafunction only for internal use within absl.
+
+
+#if defined(ABSL_HAVE_STD_IS_TRIVIALLY_COPYABLE)
+template <typename T>
+struct is_trivially_copyable : std::is_trivially_copyable<T> {};
+#else
template <typename T>
class is_trivially_copyable_impl {
using ExtentsRemoved = typename std::remove_all_extents<T>::type;
@@ -540,6 +562,7 @@ template <typename T>
struct is_trivially_copyable
: std::integral_constant<
bool, type_traits_internal::is_trivially_copyable_impl<T>::kValue> {};
+#endif
} // namespace type_traits_internal
// -----------------------------------------------------------------------------
diff --git a/chromium/third_party/abseil-cpp/absl/meta/type_traits_test.cc b/chromium/third_party/abseil-cpp/absl/meta/type_traits_test.cc
index 1aafd0d49a8..b14095ccbf6 100644
--- a/chromium/third_party/abseil-cpp/absl/meta/type_traits_test.cc
+++ b/chromium/third_party/abseil-cpp/absl/meta/type_traits_test.cc
@@ -336,6 +336,7 @@ struct MovableNonCopyable {
struct NonCopyableOrMovable {
NonCopyableOrMovable() = default;
+ virtual ~NonCopyableOrMovable() = default;
NonCopyableOrMovable(const NonCopyableOrMovable&) = delete;
NonCopyableOrMovable(NonCopyableOrMovable&&) = delete;
NonCopyableOrMovable& operator=(const NonCopyableOrMovable&) = delete;