summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2018-06-20 13:56:25 +0000
committerSam McCall <sam.mccall@gmail.com>2018-06-20 13:56:25 +0000
commit03953093f9805013b7e19a93c5885034dbd76577 (patch)
tree0fdbad477a9f38f5c171f009be7405b77dcc8841
parentd8b780dcd6574fb2bb71ca4b037fb9ff90b14505 (diff)
downloadbcm5719-llvm-03953093f9805013b7e19a93c5885034dbd76577.tar.gz
bcm5719-llvm-03953093f9805013b7e19a93c5885034dbd76577.zip
[ADT] Allow llvm::hash_code as DenseMap key.
Summary: This is useful when hash collisions are unlikely and acceptable, e.g. in clangd completion ranking. Reviewers: ioeric Subscribers: ilya-biryukov, llvm-commits Differential Revision: https://reviews.llvm.org/D48361 llvm-svn: 335125
-rw-r--r--llvm/include/llvm/ADT/DenseMapInfo.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/include/llvm/ADT/DenseMapInfo.h b/llvm/include/llvm/ADT/DenseMapInfo.h
index a96904c7dbb..5d12b424fb3 100644
--- a/llvm/include/llvm/ADT/DenseMapInfo.h
+++ b/llvm/include/llvm/ADT/DenseMapInfo.h
@@ -262,6 +262,13 @@ template <typename T> struct DenseMapInfo<ArrayRef<T>> {
}
};
+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
OpenPOWER on IntegriCloud