[DenseMapInfo] Move hash_code implementation to Hashing.h (NFC)
authorNikita Popov <nikita.ppv@gmail.com>
Thu, 7 Oct 2021 21:26:45 +0000 (23:26 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 8 Oct 2021 19:44:29 +0000 (21:44 +0200)
This moves the DenseMapInfo implementation for hash_code into
Hashing.h, removing the need to include Hashing.h (and thus <string>)
in DenseMapInfo.h. This follows the general convention of declaring
DenseMapInfo for types that we own in the respective header. The
remaining implementations in DenseMapInfo.h are all for types we
do not own.

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

llvm/include/llvm/ADT/DenseMapInfo.h
llvm/include/llvm/ADT/Hashing.h

index b1376a95d336d91a7147e422ca3da41332d08140..74c833ac25221ed8406d6d18abec410f057f87f5 100644 (file)
@@ -13,7 +13,6 @@
 #ifndef LLVM_ADT_DENSEMAPINFO_H
 #define LLVM_ADT_DENSEMAPINFO_H
 
-#include "llvm/ADT/Hashing.h"
 #include <cassert>
 #include <cstddef>
 #include <cstdint>
@@ -283,13 +282,6 @@ template <typename... Ts> struct DenseMapInfo<std::tuple<Ts...>> {
   }
 };
 
-template <> struct DenseMapInfo<hash_code> {
-  static inline hash_code getEmptyKey() { return hash_code(-1); }
-  static inline hash_code getTombstoneKey() { return hash_code(-2); }
-  static unsigned getHashValue(hash_code val) { return val; }
-  static bool isEqual(hash_code LHS, hash_code RHS) { return LHS == RHS; }
-};
-
 } // end namespace llvm
 
 #endif // LLVM_ADT_DENSEMAPINFO_H
index e296c1c53ebd17c94062b21f95d712e3a99e38c1..5c47007838896c9048033513d600a729c11d06c0 100644 (file)
@@ -56,6 +56,7 @@
 #include <utility>
 
 namespace llvm {
+template <typename T> struct DenseMapInfo;
 
 /// An opaque object representing a hash code.
 ///
@@ -677,6 +678,13 @@ hash_code hash_value(const std::basic_string<T> &arg) {
   return hash_combine_range(arg.begin(), arg.end());
 }
 
+template <> struct DenseMapInfo<hash_code> {
+  static inline hash_code getEmptyKey() { return hash_code(-1); }
+  static inline hash_code getTombstoneKey() { return hash_code(-2); }
+  static unsigned getHashValue(hash_code val) { return val; }
+  static bool isEqual(hash_code LHS, hash_code RHS) { return LHS == RHS; }
+};
+
 } // namespace llvm
 
 #endif