diff --git a/llvm/include/llvm/ADT/Hashing.h b/llvm/include/llvm/ADT/Hashing.h index ad131015a7d99..ec22fe3a28cf9 100644 --- a/llvm/include/llvm/ADT/Hashing.h +++ b/llvm/include/llvm/ADT/Hashing.h @@ -349,20 +349,16 @@ template struct is_hashable_data > sizeof(std::pair))> {}; /// Helper to get the hashable data representation for a type. -/// This variant is enabled when the type itself can be used. -template -std::enable_if_t::value, T> -get_hashable_data(const T &value) { - return value; -} -/// Helper to get the hashable data representation for a type. -/// This variant is enabled when we must first call hash_value and use the -/// result as our data. -template -std::enable_if_t::value, size_t> -get_hashable_data(const T &value) { - using ::llvm::hash_value; - return hash_value(value); +template auto get_hashable_data(const T &value) { + if constexpr (is_hashable_data::value) { + // This variant is enabled when the type itself can be used. + return value; + } else { + // This variant is enabled when we must first call hash_value and use the + // result as our data. + using ::llvm::hash_value; + return static_cast(hash_value(value)); + } } /// Helper to store data from a value into a buffer and advance the