[PATCH] D108124: Fix type in DenseMap<BitVector, *> to math for V.size()

Renato Golin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 16 05:18:00 PDT 2021


rengolin created this revision.
rengolin added reviewers: aganea, serge-sans-paille.
Herald added a subscriber: dexonsmith.
rengolin requested review of this revision.
Herald added a project: LLVM.

There are many cases in LLVM and Clang where implicit conversions from `size_t` to `unsigned` are assumed correct.

This handles one case where it isn't, by changing the template type to `size_t` to match `V.size()`.

This was caught by MSVC 19.

I can send a fix for the other warnings later on a separate patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108124

Files:
  llvm/include/llvm/ADT/BitVector.h
  llvm/include/llvm/ADT/SmallBitVector.h


Index: llvm/include/llvm/ADT/SmallBitVector.h
===================================================================
--- llvm/include/llvm/ADT/SmallBitVector.h
+++ llvm/include/llvm/ADT/SmallBitVector.h
@@ -721,7 +721,7 @@
   }
   static unsigned getHashValue(const SmallBitVector &V) {
     uintptr_t Store;
-    return DenseMapInfo<std::pair<unsigned, ArrayRef<uintptr_t>>>::getHashValue(
+    return DenseMapInfo<std::pair<size_t, ArrayRef<uintptr_t>>>::getHashValue(
         std::make_pair(V.size(), V.getData(Store)));
   }
   static bool isEqual(const SmallBitVector &LHS, const SmallBitVector &RHS) {
Index: llvm/include/llvm/ADT/BitVector.h
===================================================================
--- llvm/include/llvm/ADT/BitVector.h
+++ llvm/include/llvm/ADT/BitVector.h
@@ -824,7 +824,7 @@
     return V;
   }
   static unsigned getHashValue(const BitVector &V) {
-    return DenseMapInfo<std::pair<unsigned, ArrayRef<uintptr_t>>>::getHashValue(
+    return DenseMapInfo<std::pair<size_t, ArrayRef<uintptr_t>>>::getHashValue(
         std::make_pair(V.size(), V.getData()));
   }
   static bool isEqual(const BitVector &LHS, const BitVector &RHS) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108124.366599.patch
Type: text/x-patch
Size: 1170 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210816/ec6e7f6c/attachment.bin>


More information about the llvm-commits mailing list