diff options
author | Fangrui Song <i@maskray.me> | 2020-12-02 09:58:08 -0800 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2020-12-02 09:58:08 -0800 |
commit | 557b00e0afb2dc1776f50948094ca8cc62d97be4 (patch) | |
tree | e5673cdd4d588bd76b838a6182f3431f72921ba4 | |
parent | 4d4bd40b578d77b8c5bc349ded405fb58c333c78 (diff) | |
download | llvm-557b00e0afb2dc1776f50948094ca8cc62d97be4.zip llvm-557b00e0afb2dc1776f50948094ca8cc62d97be4.tar.gz llvm-557b00e0afb2dc1776f50948094ca8cc62d97be4.tar.bz2 |
Delete llvm::is_trivially_copyable and CMake variable HAVE_STD_IS_TRIVIALLY_COPYABLE
GCC<5 did not support std::is_trivially_copyable. Now LLVM builds
require 5.1 we can delete llvm::is_trivially_copyable after the users
have been migrated to std::is_trivially_copyable.
-rw-r--r-- | llvm/cmake/config-ix.cmake | 9 | ||||
-rw-r--r-- | llvm/include/llvm/ADT/PointerIntPair.h | 14 | ||||
-rw-r--r-- | llvm/include/llvm/Config/config.h.cmake | 3 | ||||
-rw-r--r-- | llvm/include/llvm/Support/type_traits.h | 77 | ||||
-rw-r--r-- | llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn | 1 |
5 files changed, 0 insertions, 104 deletions
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake index 818fafb..b4c54da 100644 --- a/llvm/cmake/config-ix.cmake +++ b/llvm/cmake/config-ix.cmake @@ -351,15 +351,6 @@ else() unset(HAVE_FFI_CALL CACHE) endif( LLVM_ENABLE_FFI ) -# Whether we can use std::is_trivially_copyable to verify llvm::is_trivially_copyable. -CHECK_CXX_SOURCE_COMPILES(" -#include <type_traits> -struct T { int val; }; -static_assert(std::is_trivially_copyable<T>::value, \"ok\"); -int main() { return 0;} -" HAVE_STD_IS_TRIVIALLY_COPYABLE) - - # Define LLVM_HAS_ATOMICS if gcc or MSVC atomic builtins are supported. include(CheckAtomic) diff --git a/llvm/include/llvm/ADT/PointerIntPair.h b/llvm/include/llvm/ADT/PointerIntPair.h index cb8b202..600fceb 100644 --- a/llvm/include/llvm/ADT/PointerIntPair.h +++ b/llvm/include/llvm/ADT/PointerIntPair.h @@ -15,7 +15,6 @@ #include "llvm/Support/Compiler.h" #include "llvm/Support/PointerLikeTypeTraits.h" -#include "llvm/Support/type_traits.h" #include <cassert> #include <cstdint> #include <limits> @@ -127,19 +126,6 @@ public: } }; -// Specialize is_trivially_copyable to avoid limitation of llvm::is_trivially_copyable -// when compiled with gcc 4.9. -template <typename PointerTy, unsigned IntBits, typename IntType, - typename PtrTraits, - typename Info> -struct is_trivially_copyable<PointerIntPair<PointerTy, IntBits, IntType, PtrTraits, Info>> : std::true_type { -#ifdef HAVE_STD_IS_TRIVIALLY_COPYABLE - static_assert(std::is_trivially_copyable<PointerIntPair<PointerTy, IntBits, IntType, PtrTraits, Info>>::value, - "inconsistent behavior between llvm:: and std:: implementation of is_trivially_copyable"); -#endif -}; - - template <typename PointerT, unsigned IntBits, typename PtrTraits> struct PointerIntPairInfo { static_assert(PtrTraits::NumLowBitsAvailable < diff --git a/llvm/include/llvm/Config/config.h.cmake b/llvm/include/llvm/Config/config.h.cmake index 6664ad3..4da1d19 100644 --- a/llvm/include/llvm/Config/config.h.cmake +++ b/llvm/include/llvm/Config/config.h.cmake @@ -332,9 +332,6 @@ /* Define as the return type of signal handlers (`int' or `void'). */ #cmakedefine RETSIGTYPE ${RETSIGTYPE} -/* Define if std::is_trivially_copyable is supported */ -#cmakedefine HAVE_STD_IS_TRIVIALLY_COPYABLE ${HAVE_STD_IS_TRIVIALLY_COPYABLE} - /* Define to a function implementing stricmp */ #cmakedefine stricmp ${stricmp} diff --git a/llvm/include/llvm/Support/type_traits.h b/llvm/include/llvm/Support/type_traits.h index 7b7d5d9..383f087 100644 --- a/llvm/include/llvm/Support/type_traits.h +++ b/llvm/include/llvm/Support/type_traits.h @@ -85,11 +85,6 @@ template<typename T> union move_construction_triviality_helper { ~move_construction_triviality_helper() = default; }; -template<class T> -union trivial_helper { - T t; -}; - } // end namespace detail /// An implementation of `std::is_trivially_copy_constructible` since we have @@ -114,78 +109,6 @@ struct is_trivially_move_constructible<T &> : std::true_type {}; template <typename T> struct is_trivially_move_constructible<T &&> : std::true_type {}; - -template <typename T> -struct is_copy_assignable { - template<class F> - static auto get(F*) -> decltype(std::declval<F &>() = std::declval<const F &>(), std::true_type{}); - static std::false_type get(...); - static constexpr bool value = decltype(get((T*)nullptr))::value; -}; - -template <typename T> -struct is_move_assignable { - template<class F> - static auto get(F*) -> decltype(std::declval<F &>() = std::declval<F &&>(), std::true_type{}); - static std::false_type get(...); - static constexpr bool value = decltype(get((T*)nullptr))::value; -}; - - -// An implementation of `std::is_trivially_copyable` since STL version -// is not equally supported by all compilers, especially GCC 4.9. -// Uniform implementation of this trait is important for ABI compatibility -// as it has an impact on SmallVector's ABI (among others). -template <typename T> -class is_trivially_copyable { - - // copy constructors - static constexpr bool has_trivial_copy_constructor = - std::is_copy_constructible<detail::trivial_helper<T>>::value; - static constexpr bool has_deleted_copy_constructor = - !std::is_copy_constructible<T>::value; - - // move constructors - static constexpr bool has_trivial_move_constructor = - std::is_move_constructible<detail::trivial_helper<T>>::value; - static constexpr bool has_deleted_move_constructor = - !std::is_move_constructible<T>::value; - - // copy assign - static constexpr bool has_trivial_copy_assign = - is_copy_assignable<detail::trivial_helper<T>>::value; - static constexpr bool has_deleted_copy_assign = - !is_copy_assignable<T>::value; - - // move assign - static constexpr bool has_trivial_move_assign = - is_move_assignable<detail::trivial_helper<T>>::value; - static constexpr bool has_deleted_move_assign = - !is_move_assignable<T>::value; - - // destructor - static constexpr bool has_trivial_destructor = - std::is_destructible<detail::trivial_helper<T>>::value; - - public: - - static constexpr bool value = - has_trivial_destructor && - (has_deleted_move_assign || has_trivial_move_assign) && - (has_deleted_move_constructor || has_trivial_move_constructor) && - (has_deleted_copy_assign || has_trivial_copy_assign) && - (has_deleted_copy_constructor || has_trivial_copy_constructor); - -#ifdef HAVE_STD_IS_TRIVIALLY_COPYABLE - static_assert(value == std::is_trivially_copyable<T>::value, - "inconsistent behavior between llvm:: and std:: implementation of is_trivially_copyable"); -#endif -}; -template <typename T> -class is_trivially_copyable<T*> : public std::true_type { -}; - - } // end namespace llvm #endif // LLVM_SUPPORT_TYPE_TRAITS_H diff --git a/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn b/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn index 389d5e9..193a594 100644 --- a/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn +++ b/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn @@ -89,7 +89,6 @@ write_cmake_config("config") { "HAVE_LIBPSAPI=", "HAVE_MALLCTL=", "HAVE_SIGNAL_H=1", - "HAVE_STD_IS_TRIVIALLY_COPYABLE=1", "HAVE_STRERROR=1", "HAVE_SYS_STAT_H=1", "HAVE_SYS_TYPES_H=1", |