[llvm] r265880 - Fix hash_integer_value

JF Bastien via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 9 13:25:02 PDT 2016


Author: jfb
Date: Sat Apr  9 15:25:02 2016
New Revision: 265880

URL: http://llvm.org/viewvc/llvm-project?rev=265880&view=rev
Log:
Fix hash_integer_value

Broken in D18938 because underlying_type only works for enums and not all stdlibs are sad when given a non-enum. Bots error out with 'only enumeration types have underlying types'.

There's probably a clever enable_if-ism that I can do with underlying_type and the actual integer value, but is_integral_or_enum also accepts implicit conversion so I need to ponder my life choices a bit before committing to template magic. A quick fix for now.

Modified:
    llvm/trunk/include/llvm/ADT/Hashing.h

Modified: llvm/trunk/include/llvm/ADT/Hashing.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Hashing.h?rev=265880&r1=265879&r2=265880&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/Hashing.h (original)
+++ llvm/trunk/include/llvm/ADT/Hashing.h Sat Apr  9 15:25:02 2016
@@ -633,7 +633,7 @@ template <typename T>
 typename std::enable_if<is_integral_or_enum<T>::value, hash_code>::type
 hash_value(T value) {
   return ::llvm::hashing::detail::hash_integer_value(
-      static_cast<typename std::underlying_type<T>::type>(value));
+      static_cast<uint64_t>(value));
 }
 
 // Declared and documented above, but defined here so that any of the hashing




More information about the llvm-commits mailing list