[PATCH] Hashing.h: assume support for variadic templates

Jay Foad jay.foad at gmail.com
Thu May 1 01:15:37 PDT 2014


Hi,

Is it OK to apply piecemeal cleanups like this, now that we require a C++11
compiler to build with, so variadic templates will always be supported?

Thanks,
Jay.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140501/cfdce491/attachment.html>
-------------- next part --------------
Index: include/llvm/ADT/Hashing.h
===================================================================
--- include/llvm/ADT/Hashing.h	(revision 207738)
+++ include/llvm/ADT/Hashing.h	(working copy)
@@ -55,12 +55,6 @@
 #include <iterator>
 #include <utility>
 
-// Allow detecting C++11 feature availability when building with Clang without
-// breaking other compilers.
-#ifndef __has_feature
-# define __has_feature(x) 0
-#endif
-
 namespace llvm {
 
 /// \brief An opaque object representing a hash code.
@@ -553,8 +547,6 @@
     return buffer_ptr;
   }
 
-#if defined(__has_feature) && __has_feature(__cxx_variadic_templates__)
-
   /// \brief Recursive, variadic combining method.
   ///
   /// This function recurses through each argument, combining that argument
@@ -568,53 +560,6 @@
     return combine(length, buffer_ptr, buffer_end, args...);
   }
 
-#else
-  // Manually expanded recursive combining methods. See variadic above for
-  // documentation.
-
-  template <typename T1, typename T2, typename T3, typename T4, typename T5,
-            typename T6>
-  hash_code combine(size_t length, char *buffer_ptr, char *buffer_end,
-                    const T1 &arg1, const T2 &arg2, const T3 &arg3,
-                    const T4 &arg4, const T5 &arg5, const T6 &arg6) {
-    buffer_ptr = combine_data(length, buffer_ptr, buffer_end, get_hashable_data(arg1));
-    return combine(length, buffer_ptr, buffer_end, arg2, arg3, arg4, arg5, arg6);
-  }
-  template <typename T1, typename T2, typename T3, typename T4, typename T5>
-  hash_code combine(size_t length, char *buffer_ptr, char *buffer_end,
-                    const T1 &arg1, const T2 &arg2, const T3 &arg3,
-                    const T4 &arg4, const T5 &arg5) {
-    buffer_ptr = combine_data(length, buffer_ptr, buffer_end, get_hashable_data(arg1));
-    return combine(length, buffer_ptr, buffer_end, arg2, arg3, arg4, arg5);
-  }
-  template <typename T1, typename T2, typename T3, typename T4>
-  hash_code combine(size_t length, char *buffer_ptr, char *buffer_end,
-                    const T1 &arg1, const T2 &arg2, const T3 &arg3,
-                    const T4 &arg4) {
-    buffer_ptr = combine_data(length, buffer_ptr, buffer_end, get_hashable_data(arg1));
-    return combine(length, buffer_ptr, buffer_end, arg2, arg3, arg4);
-  }
-  template <typename T1, typename T2, typename T3>
-  hash_code combine(size_t length, char *buffer_ptr, char *buffer_end,
-                    const T1 &arg1, const T2 &arg2, const T3 &arg3) {
-    buffer_ptr = combine_data(length, buffer_ptr, buffer_end, get_hashable_data(arg1));
-    return combine(length, buffer_ptr, buffer_end, arg2, arg3);
-  }
-  template <typename T1, typename T2>
-  hash_code combine(size_t length, char *buffer_ptr, char *buffer_end,
-                    const T1 &arg1, const T2 &arg2) {
-    buffer_ptr = combine_data(length, buffer_ptr, buffer_end, get_hashable_data(arg1));
-    return combine(length, buffer_ptr, buffer_end, arg2);
-  }
-  template <typename T1>
-  hash_code combine(size_t length, char *buffer_ptr, char *buffer_end,
-                    const T1 &arg1) {
-    buffer_ptr = combine_data(length, buffer_ptr, buffer_end, get_hashable_data(arg1));
-    return combine(length, buffer_ptr, buffer_end);
-  }
-
-#endif
-
   /// \brief Base case for recursive, variadic combining.
   ///
   /// The base case when combining arguments recursively is reached when all
@@ -644,8 +589,6 @@
 } // namespace hashing
 
 
-#if __has_feature(__cxx_variadic_templates__)
-
 /// \brief Combine values into a single hash_code.
 ///
 /// This routine accepts a varying number of arguments of any type. It will
@@ -663,51 +606,6 @@
   return helper.combine(0, helper.buffer, helper.buffer + 64, args...);
 }
 
-#else
-
-// What follows are manually exploded overloads for each argument width. See
-// the above variadic definition for documentation and specification.
-
-template <typename T1, typename T2, typename T3, typename T4, typename T5,
-          typename T6>
-hash_code hash_combine(const T1 &arg1, const T2 &arg2, const T3 &arg3,
-                       const T4 &arg4, const T5 &arg5, const T6 &arg6) {
-  ::llvm::hashing::detail::hash_combine_recursive_helper helper;
-  return helper.combine(0, helper.buffer, helper.buffer + 64,
-                        arg1, arg2, arg3, arg4, arg5, arg6);
-}
-template <typename T1, typename T2, typename T3, typename T4, typename T5>
-hash_code hash_combine(const T1 &arg1, const T2 &arg2, const T3 &arg3,
-                       const T4 &arg4, const T5 &arg5) {
-  ::llvm::hashing::detail::hash_combine_recursive_helper helper;
-  return helper.combine(0, helper.buffer, helper.buffer + 64,
-                        arg1, arg2, arg3, arg4, arg5);
-}
-template <typename T1, typename T2, typename T3, typename T4>
-hash_code hash_combine(const T1 &arg1, const T2 &arg2, const T3 &arg3,
-                       const T4 &arg4) {
-  ::llvm::hashing::detail::hash_combine_recursive_helper helper;
-  return helper.combine(0, helper.buffer, helper.buffer + 64,
-                        arg1, arg2, arg3, arg4);
-}
-template <typename T1, typename T2, typename T3>
-hash_code hash_combine(const T1 &arg1, const T2 &arg2, const T3 &arg3) {
-  ::llvm::hashing::detail::hash_combine_recursive_helper helper;
-  return helper.combine(0, helper.buffer, helper.buffer + 64, arg1, arg2, arg3);
-}
-template <typename T1, typename T2>
-hash_code hash_combine(const T1 &arg1, const T2 &arg2) {
-  ::llvm::hashing::detail::hash_combine_recursive_helper helper;
-  return helper.combine(0, helper.buffer, helper.buffer + 64, arg1, arg2);
-}
-template <typename T1>
-hash_code hash_combine(const T1 &arg1) {
-  ::llvm::hashing::detail::hash_combine_recursive_helper helper;
-  return helper.combine(0, helper.buffer, helper.buffer + 64, arg1);
-}
-
-#endif
-
 
 // Implementation details for implementations of hash_value overloads provided
 // here.


More information about the llvm-commits mailing list