From d676385fb408da3dac3c14f3f62ac0197e24370c Mon Sep 17 00:00:00 2001 From: greg7mdp Date: Sat, 19 Nov 2022 14:25:19 -0500 Subject: [PATCH] Fix clang-15 warnings --- parallel_hashmap/btree.h | 23 ++++++++--------------- parallel_hashmap/phmap_base.h | 30 ++++-------------------------- parallel_hashmap/phmap_config.h | 27 --------------------------- tests/btree_test.cc | 2 +- 4 files changed, 13 insertions(+), 69 deletions(-) diff --git a/parallel_hashmap/btree.h b/parallel_hashmap/btree.h index 8aee516..f584981 100644 --- a/parallel_hashmap/btree.h +++ b/parallel_hashmap/btree.h @@ -60,6 +60,7 @@ #include #include #include +#include #include "phmap_fwd_decl.h" #include "phmap_base.h" @@ -76,14 +77,6 @@ namespace phmap { - // Defined and documented later on in this file. - template - struct is_trivially_destructible; - - // Defined and documented later on in this file. - template - struct is_trivially_move_assignable; - namespace type_traits_internal { // Silence MSVC warnings about the destructor being defined as deleted. @@ -107,25 +100,25 @@ namespace phmap { : std::integral_constant< bool, std::is_move_constructible< type_traits_internal::SingleMemberUnion>::value && - phmap::is_trivially_destructible::value> {}; + std::is_trivially_destructible::value> {}; template struct IsTriviallyCopyConstructibleObject : std::integral_constant< bool, std::is_copy_constructible< type_traits_internal::SingleMemberUnion>::value && - phmap::is_trivially_destructible::value> {}; + std::is_trivially_destructible::value> {}; template struct IsTriviallyMoveAssignableReference : std::false_type {}; template struct IsTriviallyMoveAssignableReference - : phmap::is_trivially_move_assignable::type {}; + : std::is_trivially_move_assignable::type {}; template struct IsTriviallyMoveAssignableReference - : phmap::is_trivially_move_assignable::type {}; + : std::is_trivially_move_assignable::type {}; } // namespace type_traits_internal @@ -155,10 +148,10 @@ namespace phmap { public: static constexpr bool kValue = - (__has_trivial_copy(ExtentsRemoved) || !kIsCopyOrMoveConstructible) && - (__has_trivial_assign(ExtentsRemoved) || !kIsCopyOrMoveAssignable) && + (std::is_trivially_copyable::value || !kIsCopyOrMoveConstructible) && + (std::is_trivially_copy_assignable::value || !kIsCopyOrMoveAssignable) && (kIsCopyOrMoveConstructible || kIsCopyOrMoveAssignable) && - is_trivially_destructible::value && + std::is_trivially_destructible::value && // We need to check for this explicitly because otherwise we'll say // references are trivial copyable when compiled by MSVC. !std::is_reference::value; diff --git a/parallel_hashmap/phmap_base.h b/parallel_hashmap/phmap_base.h index 0cb8931..5705970 100644 --- a/parallel_hashmap/phmap_base.h +++ b/parallel_hashmap/phmap_base.h @@ -223,29 +223,6 @@ struct disjunction<> : std::false_type {}; template struct negation : std::integral_constant {}; -template -struct is_trivially_destructible - : std::integral_constant::value> {}; - -template -struct is_trivially_default_constructible - : std::integral_constant::value && - is_trivially_destructible::value> {}; - -template -struct is_trivially_copy_constructible - : std::integral_constant::value && - is_trivially_destructible::value> {}; - -template -struct is_trivially_copy_assignable - : std::integral_constant< - bool, __has_trivial_assign(typename std::remove_reference::type) && - phmap::is_copy_assignable::value> {}; - // ----------------------------------------------------------------------------- // C++14 "_t" trait aliases // ----------------------------------------------------------------------------- @@ -1808,9 +1785,10 @@ protected: // Also, we should be checking is_trivially_copyable here, which is not // supported now, so we use is_trivially_* traits instead. template ::value&& - phmap::is_trivially_copy_assignable::type>::value&& std::is_trivially_destructible::value> + bool unused = + std::is_trivially_copy_constructible::value && + std::is_trivially_copy_assignable::type>::value && + std::is_trivially_destructible::value> class optional_data; // Trivially copyable types diff --git a/parallel_hashmap/phmap_config.h b/parallel_hashmap/phmap_config.h index 18434f6..9f32a81 100644 --- a/parallel_hashmap/phmap_config.h +++ b/parallel_hashmap/phmap_config.h @@ -148,33 +148,6 @@ #define PHMAP_INTERNAL_HAVE_MIN_CLANG_VERSION(x, y) 0 #endif -// ---------------------------------------------------------------- -// Checks whether `std::is_trivially_destructible` is supported. -// ---------------------------------------------------------------- -#ifdef PHMAP_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE - #error PHMAP_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE cannot be directly set -#elif defined(_LIBCPP_VERSION) || defined(_MSC_VER) || \ - (!defined(__clang__) && defined(__GNUC__) && defined(__GLIBCXX__) && PHMAP_INTERNAL_HAVE_MIN_GNUC_VERSION(4, 8)) - #define PHMAP_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE 1 -#endif - -// -------------------------------------------------------------- -// Checks whether `std::is_trivially_default_constructible` is -// supported. -// -------------------------------------------------------------- -#if defined(PHMAP_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE) - #error PHMAP_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE cannot be directly set -#elif defined(PHMAP_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE) - #error PHMAP_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE cannot directly set -#elif (defined(__clang__) && defined(_LIBCPP_VERSION)) || \ - (!defined(__clang__) && defined(__GNUC__) && \ - PHMAP_INTERNAL_HAVE_MIN_GNUC_VERSION(5, 1) && \ - (defined(_LIBCPP_VERSION) || defined(__GLIBCXX__))) || \ - (defined(_MSC_VER) && !defined(__NVCC__)) - #define PHMAP_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE 1 - #define PHMAP_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE 1 -#endif - // ------------------------------------------------------------------- // Checks whether C++11's `thread_local` storage duration specifier is // supported. diff --git a/tests/btree_test.cc b/tests/btree_test.cc index 80a114a..dce9497 100644 --- a/tests/btree_test.cc +++ b/tests/btree_test.cc @@ -418,7 +418,7 @@ namespace { }; template - void DoTest(const char *name, T *b, const std::vector &values) { + void DoTest(const char *, T *b, const std::vector &values) { typename KeyOfValue::type key_of_value; T &mutable_b = *b;