[llvm] 8830369 - Do not downcast uint64_t to unsigned in UniqueID hash computation

Kirill Bobyrev via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 21 07:26:47 PDT 2021


Author: Kirill Bobyrev
Date: 2021-10-21T16:23:31+02:00
New Revision: 88303693ce97cf842f0714068c2cae44cd6515e1

URL: https://github.com/llvm/llvm-project/commit/88303693ce97cf842f0714068c2cae44cd6515e1
DIFF: https://github.com/llvm/llvm-project/commit/88303693ce97cf842f0714068c2cae44cd6515e1.diff

LOG: Do not downcast uint64_t to unsigned in UniqueID hash computation

Context: https://reviews.llvm.org/D110925#inline-1070046

Added: 
    

Modified: 
    llvm/include/llvm/Support/FileSystem/UniqueID.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Support/FileSystem/UniqueID.h b/llvm/include/llvm/Support/FileSystem/UniqueID.h
index 49ebe44032b86..f3dfb367401a6 100644
--- a/llvm/include/llvm/Support/FileSystem/UniqueID.h
+++ b/llvm/include/llvm/Support/FileSystem/UniqueID.h
@@ -54,19 +54,18 @@ class UniqueID {
 // Support UniqueIDs as DenseMap keys.
 template <> struct DenseMapInfo<llvm::sys::fs::UniqueID> {
   static inline llvm::sys::fs::UniqueID getEmptyKey() {
-    auto EmptyKey = DenseMapInfo<std::pair<unsigned, unsigned>>::getEmptyKey();
+    auto EmptyKey = DenseMapInfo<std::pair<uint64_t, uint64_t>>::getEmptyKey();
     return {EmptyKey.first, EmptyKey.second};
   }
 
   static inline llvm::sys::fs::UniqueID getTombstoneKey() {
     auto TombstoneKey =
-        DenseMapInfo<std::pair<unsigned, unsigned>>::getTombstoneKey();
+        DenseMapInfo<std::pair<uint64_t, uint64_t>>::getTombstoneKey();
     return {TombstoneKey.first, TombstoneKey.second};
   }
 
   static unsigned getHashValue(const llvm::sys::fs::UniqueID &Tag) {
-    return hash_value(
-        std::pair<unsigned, unsigned>(Tag.getDevice(), Tag.getFile()));
+    return hash_value(std::make_pair(Tag.getDevice(), Tag.getFile()));
   }
 
   static bool isEqual(const llvm::sys::fs::UniqueID &LHS,


        


More information about the llvm-commits mailing list