[llvm] 01ffe31 - [llvm] Remove llvm::is_trivially_{copy/move}_constructible (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 20 14:06:51 PDT 2022


Author: Kazu Hirata
Date: 2022-08-20T14:06:42-07:00
New Revision: 01ffe31cbb54bfd8e38e71b3cf804a1d67ebf9c1

URL: https://github.com/llvm/llvm-project/commit/01ffe31cbb54bfd8e38e71b3cf804a1d67ebf9c1
DIFF: https://github.com/llvm/llvm-project/commit/01ffe31cbb54bfd8e38e71b3cf804a1d67ebf9c1.diff

LOG: [llvm] Remove llvm::is_trivially_{copy/move}_constructible (NFC)

This patch removes llvm::is_trivially_{copy/move}_constructible in
favor of std::is_trivially_{copy/move}_constructible.

The previous attempt to remove them in Dec 2020,
c8d406c93c5bb01599990201f78d8428dd29d289, broke builds with "some
versions of GCC" according to
6cd9608fb37ca2418fb44b57ec955bb5efe10689.

It's been 20 months since then, and the minimum requirement for GCC
has been updated to 7.1 from 5.1.

FWIW, I was able to build llvm with gcc 8.4.0.

Differential Revision: https://reviews.llvm.org/D132311

Added: 
    

Modified: 
    llvm/include/llvm/ADT/FunctionExtras.h
    llvm/include/llvm/ADT/Optional.h
    llvm/include/llvm/ADT/SmallVector.h
    llvm/include/llvm/Support/type_traits.h
    llvm/unittests/Support/TypeTraitsTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h
index 8ff0fb787a77d..27fff59115a8d 100644
--- a/llvm/include/llvm/ADT/FunctionExtras.h
+++ b/llvm/include/llvm/ADT/FunctionExtras.h
@@ -59,7 +59,7 @@ namespace detail {
 
 template <typename T>
 using EnableIfTrivial =
-    std::enable_if_t<llvm::is_trivially_move_constructible<T>::value &&
+    std::enable_if_t<std::is_trivially_move_constructible<T>::value &&
                      std::is_trivially_destructible<T>::value>;
 template <typename CallableT, typename ThisT>
 using EnableUnlessSameType =
@@ -100,8 +100,8 @@ template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
     static_assert(!std::is_reference<T>::value,
                   "references should be handled by template specialization");
     using type = typename std::conditional<
-        llvm::is_trivially_copy_constructible<T>::value &&
-            llvm::is_trivially_move_constructible<T>::value &&
+        std::is_trivially_copy_constructible<T>::value &&
+            std::is_trivially_move_constructible<T>::value &&
             IsSizeLessThanThresholdT<T>::value,
         T, T &>::type;
   };

diff  --git a/llvm/include/llvm/ADT/Optional.h b/llvm/include/llvm/ADT/Optional.h
index 0f4e500834855..3ff591d6a1772 100644
--- a/llvm/include/llvm/ADT/Optional.h
+++ b/llvm/include/llvm/ADT/Optional.h
@@ -50,13 +50,12 @@ namespace optional_detail {
 //
 // The move constructible / assignable conditions emulate the remaining behavior
 // of std::is_trivially_copyable.
-template <typename T,
-          bool = (llvm::is_trivially_copy_constructible<T>::value &&
-                  std::is_trivially_copy_assignable<T>::value &&
-                  (llvm::is_trivially_move_constructible<T>::value ||
-                   !std::is_move_constructible<T>::value) &&
-                  (std::is_trivially_move_assignable<T>::value ||
-                   !std::is_move_assignable<T>::value))>
+template <typename T, bool = (std::is_trivially_copy_constructible<T>::value &&
+                              std::is_trivially_copy_assignable<T>::value &&
+                              (std::is_trivially_move_constructible<T>::value ||
+                               !std::is_move_constructible<T>::value) &&
+                              (std::is_trivially_move_assignable<T>::value ||
+                               !std::is_move_assignable<T>::value))>
 class OptionalStorage {
   union {
     char empty;

diff  --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
index 167efc2b00a3a..a29886c38e3f8 100644
--- a/llvm/include/llvm/ADT/SmallVector.h
+++ b/llvm/include/llvm/ADT/SmallVector.h
@@ -312,8 +312,8 @@ class SmallVectorTemplateCommon
 /// copy these types with memcpy, there is no way for the type to observe this.
 /// This catches the important case of std::pair<POD, POD>, which is not
 /// trivially assignable.
-template <typename T, bool = (is_trivially_copy_constructible<T>::value) &&
-                             (is_trivially_move_constructible<T>::value) &&
+template <typename T, bool = (std::is_trivially_copy_constructible<T>::value) &&
+                             (std::is_trivially_move_constructible<T>::value) &&
                              std::is_trivially_destructible<T>::value>
 class SmallVectorTemplateBase : public SmallVectorTemplateCommon<T> {
   friend class SmallVectorTemplateCommon<T>;

diff  --git a/llvm/include/llvm/Support/type_traits.h b/llvm/include/llvm/Support/type_traits.h
index 7b7d5d991f3f5..534ad8c7eac93 100644
--- a/llvm/include/llvm/Support/type_traits.h
+++ b/llvm/include/llvm/Support/type_traits.h
@@ -70,21 +70,6 @@ struct const_pointer_or_const_ref<T,
 };
 
 namespace detail {
-/// Internal utility to detect trivial copy construction.
-template<typename T> union copy_construction_triviality_helper {
-    T t;
-    copy_construction_triviality_helper() = default;
-    copy_construction_triviality_helper(const copy_construction_triviality_helper&) = default;
-    ~copy_construction_triviality_helper() = default;
-};
-/// Internal utility to detect trivial move construction.
-template<typename T> union move_construction_triviality_helper {
-    T t;
-    move_construction_triviality_helper() = default;
-    move_construction_triviality_helper(move_construction_triviality_helper&&) = default;
-    ~move_construction_triviality_helper() = default;
-};
-
 template<class T>
 union trivial_helper {
     T t;
@@ -92,29 +77,6 @@ union trivial_helper {
 
 } // end namespace detail
 
-/// An implementation of `std::is_trivially_copy_constructible` since we have
-/// users with STLs that don't yet include it.
-template <typename T>
-struct is_trivially_copy_constructible
-    : std::is_copy_constructible<
-          ::llvm::detail::copy_construction_triviality_helper<T>> {};
-template <typename T>
-struct is_trivially_copy_constructible<T &> : std::true_type {};
-template <typename T>
-struct is_trivially_copy_constructible<T &&> : std::false_type {};
-
-/// An implementation of `std::is_trivially_move_constructible` since we have
-/// users with STLs that don't yet include it.
-template <typename T>
-struct is_trivially_move_constructible
-    : std::is_move_constructible<
-          ::llvm::detail::move_construction_triviality_helper<T>> {};
-template <typename T>
-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>

diff  --git a/llvm/unittests/Support/TypeTraitsTest.cpp b/llvm/unittests/Support/TypeTraitsTest.cpp
index 734e50afa2db3..a7adce9f8f248 100644
--- a/llvm/unittests/Support/TypeTraitsTest.cpp
+++ b/llvm/unittests/Support/TypeTraitsTest.cpp
@@ -26,10 +26,10 @@ namespace triviality {
 template <typename T, bool IsTriviallyCopyConstructible,
           bool IsTriviallyMoveConstructible>
 void TrivialityTester() {
-  static_assert(llvm::is_trivially_copy_constructible<T>::value ==
+  static_assert(std::is_trivially_copy_constructible<T>::value ==
                     IsTriviallyCopyConstructible,
                 "Mismatch in expected trivial copy construction!");
-  static_assert(llvm::is_trivially_move_constructible<T>::value ==
+  static_assert(std::is_trivially_move_constructible<T>::value ==
                     IsTriviallyMoveConstructible,
                 "Mismatch in expected trivial move construction!");
 


        


More information about the llvm-commits mailing list