[llvm] [ADT] Clean up DenseMap.h after removing CRTP (NFC) (PR #228981)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 4 23:24:56 PDT 2026


https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/228981

>From 4397517e61b6203b3b3586c62d980663f3cb74f6 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 29 Sep 2026 09:14:56 -0700
Subject: [PATCH 1/2] [ADT] Clean up DenseMap.h after removing CRTP (NFC)

This patch makes several minor cleanups in DenseMap.h following the
removal of CRTP.  While most changes are obvious, notable ones include:

- Drop the redundant "= 4" default argument on SmallDenseMapStorage's
  InlineBuckets template parameter, as SmallDenseMap already provides
  it.

- Inline DenseMapBase::hasher into its sole caller
  DenseMapBase::grow.

Assisted-by: Antigravity
---
 llvm/include/llvm/ADT/DenseMap.h | 126 +++++++++++++++----------------
 1 file changed, 60 insertions(+), 66 deletions(-)

diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h
index 6d25ce578a620..806dc2fc3a9ce 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -291,8 +291,7 @@ template <typename BucketT> class DenseMapStorage {
   }
 };
 
-template <typename BucketT, unsigned InlineBuckets = 4>
-class SmallDenseMapStorage {
+template <typename BucketT, unsigned InlineBuckets> class SmallDenseMapStorage {
   static_assert(isPowerOf2_64(InlineBuckets),
                 "InlineBuckets must be a power of 2.");
 
@@ -317,35 +316,36 @@ class SmallDenseMapStorage {
   union {
     InlineRep Inline;
     LargeRep Large;
-  } storage;
+  } Storage;
 
   const BucketT *getInlineBuckets() const {
     assert(Small);
     // Note that this cast does not violate aliasing rules as we assert that
     // the memory's dynamic type is the small, inline bucket buffer, and the
-    // 'storage' is a POD containing a char buffer.
-    return reinterpret_cast<const BucketT *>(storage.Inline.Buckets);
+    // 'Storage' is a POD containing a char buffer.
+    return reinterpret_cast<const BucketT *>(Storage.Inline.Buckets);
   }
 
   BucketT *getInlineBuckets() {
     assert(Small);
-    return reinterpret_cast<BucketT *>(storage.Inline.Buckets);
+    return reinterpret_cast<BucketT *>(Storage.Inline.Buckets);
   }
 
   const UsedT *getInlineUsed() const {
     assert(Small);
-    return storage.Inline.Used;
+    return Storage.Inline.Used;
   }
 
   UsedT *getInlineUsed() {
     assert(Small);
-    return storage.Inline.Used;
+    return Storage.Inline.Used;
   }
 
-  void setLarge(void *Storage, unsigned NumBuckets) {
+  void setLarge(void *NewStorage, unsigned NumBuckets) {
     Small = false;
-    storage.Large = {static_cast<BucketT *>(Storage),
-                     usedFor(Storage, sizeof(BucketT), NumBuckets), NumBuckets};
+    Storage.Large = {static_cast<BucketT *>(NewStorage),
+                     usedFor(NewStorage, sizeof(BucketT), NumBuckets),
+                     NumBuckets};
   }
 
 public:
@@ -358,7 +358,7 @@ class SmallDenseMapStorage {
   }
 
   const BucketT *getBuckets() const {
-    return Small ? getInlineBuckets() : storage.Large.Buckets;
+    return Small ? getInlineBuckets() : Storage.Large.Buckets;
   }
 
   BucketT *getBuckets() {
@@ -367,7 +367,7 @@ class SmallDenseMapStorage {
   }
 
   const UsedT *getUsed() const {
-    return Small ? getInlineUsed() : storage.Large.Used;
+    return Small ? getInlineUsed() : Storage.Large.Used;
   }
 
   UsedT *getUsed() {
@@ -376,14 +376,14 @@ class SmallDenseMapStorage {
   }
 
   unsigned getNumBuckets() const {
-    return Small ? InlineBuckets : storage.Large.NumBuckets;
+    return Small ? InlineBuckets : Storage.Large.NumBuckets;
   }
 
   StorageRep<BucketT> getRep() const {
     if (Small)
       return {getInlineBuckets(), getInlineUsed(), InlineBuckets};
-    return {storage.Large.Buckets, storage.Large.Used,
-            storage.Large.NumBuckets};
+    return {Storage.Large.Buckets, Storage.Large.Used,
+            Storage.Large.NumBuckets};
   }
 
   void swap(SmallDenseMapStorage &RHS) {
@@ -418,7 +418,7 @@ class SmallDenseMapStorage {
       return;
     }
     if (!Small && !RHS.Small) {
-      std::swap(storage.Large, RHS.storage.Large);
+      std::swap(Storage.Large, RHS.Storage.Large);
       return;
     }
 
@@ -428,7 +428,7 @@ class SmallDenseMapStorage {
     // Stash the large rep, then move the small side's inline contents into the
     // large side (which becomes inline), and finally install the rep on the
     // small side (which becomes large).
-    LargeRep TmpRep = LargeSide.storage.Large;
+    LargeRep TmpRep = LargeSide.Storage.Large;
     LargeSide.Small = true;
     {
       UsedT *SU = SmallSide.getInlineUsed(), *LU = LargeSide.getInlineUsed();
@@ -441,32 +441,32 @@ class SmallDenseMapStorage {
         LU[W] = SU[W];
     }
     SmallSide.Small = false;
-    SmallSide.storage.Large = TmpRep;
+    SmallSide.Storage.Large = TmpRep;
   }
 
   void grow(unsigned MinNumBuckets, BucketHasher Hasher) {
     unsigned NewNumBuckets = roundUpNumBuckets(MinNumBuckets);
     // remove_if asks for the count it already has: rehash in place.
     if (Small && NewNumBuckets <= InlineBuckets) {
-      InlineRep Old = storage.Inline;
+      InlineRep Old = Storage.Inline;
       clearUsed(getInlineUsed(), InlineBuckets);
       rehashRelocatable(getInlineBuckets(), getInlineUsed(), InlineBuckets,
                         Old.Buckets, Old.Used, InlineBuckets, sizeof(BucketT),
                         Hasher);
       return;
     }
-    void *Storage = growRelocatable(
+    void *NewStorage = growRelocatable(
         getBuckets(), getUsed(), getNumBuckets(), NewNumBuckets,
         sizeof(BucketT), allocAlign<BucketT>(), Hasher, /*FreeOld=*/!Small);
-    setLarge(Storage, NewNumBuckets);
+    setLarge(NewStorage, NewNumBuckets);
   }
 
   void deallocateBuckets() {
     if (Small)
       return;
 
-    deallocate_buffer(storage.Large.Buckets,
-                      allocBytes<BucketT>(storage.Large.NumBuckets),
+    deallocate_buffer(Storage.Large.Buckets,
+                      allocBytes<BucketT>(Storage.Large.NumBuckets),
                       allocAlign<BucketT>());
   }
 
@@ -497,7 +497,7 @@ class SmallDenseMapStorage {
         NewNumBuckets = std::max(64u, NewNumBuckets);
     }
     bool Reuse = Small ? NewNumBuckets <= InlineBuckets
-                       : NewNumBuckets == storage.Large.NumBuckets;
+                       : NewNumBuckets == Storage.Large.NumBuckets;
     if (Reuse)
       return {false, 0};          // Reuse.
     return {true, NewNumBuckets}; // Reallocate.
@@ -509,7 +509,7 @@ class SmallDenseMapStorage {
 
     Small = false;
     NumEntries = Other.NumEntries;
-    storage.Large = Other.storage.Large;
+    Storage.Large = Other.Storage.Large;
     return true;
   }
 };
@@ -621,9 +621,9 @@ class DenseMapIterator : DebugEpochBase::HandleBase {
   }
   DenseMapIterator operator++(int) { // Postincrement
     assert(isHandleInSync() && "invalid iterator access!");
-    DenseMapIterator tmp = *this;
+    DenseMapIterator Tmp = *this;
     ++*this;
-    return tmp;
+    return Tmp;
   }
 
 private:
@@ -717,7 +717,7 @@ class DenseMapBase : public DebugEpochBase {
   [[nodiscard]] bool empty() const { return getNumEntries() == 0; }
   [[nodiscard]] unsigned size() const { return getNumEntries(); }
 
-  /// Grow the densemap so that it can contain at least \p NumEntries items
+  /// Grow the DenseMap so that it can contain at least \p NumEntries items
   /// before resizing again.
   void reserve(size_type NumEntries) {
     auto NumBuckets = getMinBucketToReserveForEntries(NumEntries);
@@ -810,15 +810,15 @@ class DenseMapBase : public DebugEpochBase {
 
   /// Return the entry for the specified key, or abort if no such entry exists.
   [[nodiscard]] ValueT &at(const_arg_type_t<KeyT> Val) {
-    auto Iter = this->find(std::move(Val));
-    assert(Iter != this->end() && "DenseMap::at failed due to a missing key");
+    auto Iter = find(std::move(Val));
+    assert(Iter != end() && "DenseMap::at failed due to a missing key");
     return Iter->second;
   }
 
   /// Return the entry for the specified key, or abort if no such entry exists.
   [[nodiscard]] const ValueT &at(const_arg_type_t<KeyT> Val) const {
-    auto Iter = this->find(std::move(Val));
-    assert(Iter != this->end() && "DenseMap::at failed due to a missing key");
+    auto Iter = find(std::move(Val));
+    assert(Iter != end() && "DenseMap::at failed due to a missing key");
     return Iter->second;
   }
 
@@ -891,7 +891,7 @@ class DenseMapBase : public DebugEpochBase {
       insert(*I);
   }
 
-  /// Inserts range of 'std::pair<KeyT, ValueT>' values into the map.
+  /// Inserts a range of 'std::pair<KeyT, ValueT>' values into the map.
   template <typename Range> void insert_range(Range &&R) {
     insert(adl_begin(R), adl_end(R));
   }
@@ -962,7 +962,7 @@ class DenseMapBase : public DebugEpochBase {
     }
     if (Removed) {
       incrementEpoch();
-      this->grow(NumBuckets);
+      grow(NumBuckets);
     }
     return Removed;
   }
@@ -976,7 +976,7 @@ class DenseMapBase : public DebugEpochBase {
   }
 
   void swap(DenseMapBase &RHS) {
-    this->incrementEpoch();
+    incrementEpoch();
     RHS.incrementEpoch();
     Storage.swap(RHS.Storage);
   }
@@ -990,16 +990,14 @@ class DenseMapBase : public DebugEpochBase {
         Storage, getMinBucketToReserveForEntries(NumElementsToReserve));
   }
 
-  DenseMapBase(const DenseMapBase &other) : DenseMapBase() {
-    this->copyFrom(other);
-  }
+  DenseMapBase(const DenseMapBase &Other) : DenseMapBase() { copyFrom(Other); }
 
-  DenseMapBase(DenseMapBase &&other) : DenseMapBase() { this->swap(other); }
+  DenseMapBase(DenseMapBase &&Other) : DenseMapBase() { swap(Other); }
 
   template <typename InputIt>
   DenseMapBase(const InputIt &I, const InputIt &E)
       : DenseMapBase(std::distance(I, E)) {
-    this->insert(I, E);
+    insert(I, E);
   }
 
   template <typename RangeT>
@@ -1010,28 +1008,28 @@ class DenseMapBase : public DebugEpochBase {
       : DenseMapBase(Vals.begin(), Vals.end()) {}
 
   ~DenseMapBase() {
-    this->destroyAll();
+    destroyAll();
     Storage.deallocateBuckets();
   }
 
-  DenseMapBase &operator=(const DenseMapBase &other) {
-    if (&other != this)
-      this->copyFrom(other);
+  DenseMapBase &operator=(const DenseMapBase &Other) {
+    if (&Other != this)
+      copyFrom(Other);
     return *this;
   }
 
-  DenseMapBase &operator=(DenseMapBase &&other) {
-    this->destroyAll();
+  DenseMapBase &operator=(DenseMapBase &&Other) {
+    destroyAll();
     Storage.deallocateBuckets();
     initWithExactBucketCount(Storage, 0);
-    this->swap(other);
+    swap(Other);
     return *this;
   }
 
   /// Return the approximate size (in bytes) of the actual map.
   /// This is just the raw memory used by DenseMap.
   /// If entries are pointers to objects, the size of the referenced objects
-  /// are not included.
+  /// is not included.
   [[nodiscard]] size_t getMemorySize() const {
     return llvm::densemap::detail::allocBytes<BucketT>(getNumBuckets());
   }
@@ -1077,7 +1075,7 @@ class DenseMapBase : public DebugEpochBase {
 
   /// Returns the number of buckets to allocate to ensure that the DenseMap can
   /// accommodate \p NumEntries without need to grow().
-  unsigned getMinBucketToReserveForEntries(unsigned NumEntries) {
+  static unsigned getMinBucketToReserveForEntries(unsigned NumEntries) {
     // Ensure that "NumEntries * 4 < NumBuckets * 3"
     if (NumEntries == 0)
       return 0;
@@ -1086,10 +1084,6 @@ class DenseMapBase : public DebugEpochBase {
     return NextPowerOf2(NumEntries * 4 / 3 + 1);
   }
 
-  static constexpr llvm::densemap::detail::BucketHasher hasher() {
-    return llvm::densemap::detail::hasherFor<KeyT, KeyInfoT>();
-  }
-
   // Move key/value from Src to Dst.
   static LLVM_ATTRIBUTE_NOINLINE void moveFrom(StorageT &Dst, StorageT &Src) {
     assert(Dst.getNumEntries() == 0 &&
@@ -1113,30 +1107,29 @@ class DenseMapBase : public DebugEpochBase {
     Src.deallocateBuckets();
   }
 
-  LLVM_ATTRIBUTE_NOINLINE void copyFrom(const DenseMapBase &other) {
-    this->destroyAll();
+  LLVM_ATTRIBUTE_NOINLINE void copyFrom(const DenseMapBase &Other) {
+    destroyAll();
     Storage.deallocateBuckets();
     setNumEntries(0);
-    if (!Storage.allocateBuckets(other.getNumBuckets())) {
+    if (!Storage.allocateBuckets(Other.getNumBuckets())) {
       // The bucket list is empty.  No work to do.
       return;
     }
 
-    assert(&other != this);
-    assert(getNumBuckets() == other.getNumBuckets());
+    assert(&Other != this);
+    assert(getNumBuckets() == Other.getNumBuckets());
 
-    setNumEntries(other.getNumEntries());
+    setNumEntries(Other.getNumEntries());
 
     BucketT *Buckets = getBuckets();
-    const BucketT *OtherBuckets = other.getBuckets();
+    const BucketT *OtherBuckets = Other.getBuckets();
     const unsigned NumBuckets = getNumBuckets();
     UsedT *U = getUsed();
-    const UsedT *OtherU = other.getUsed();
+    const UsedT *OtherU = Other.getUsed();
     std::memcpy(U, OtherU,
                 llvm::densemap::detail::usedWords(NumBuckets) * sizeof(UsedT));
     if constexpr (densemap::detail::isRelocatableBucket<BucketT>) {
-      memcpy(reinterpret_cast<void *>(Buckets), OtherBuckets,
-             NumBuckets * sizeof(BucketT));
+      memcpy(Buckets, OtherBuckets, NumBuckets * sizeof(BucketT));
     } else {
       llvm::densemap::detail::forEachUsed(U, NumBuckets, [&](unsigned I) {
         ::new (&Buckets[I].getFirst()) KeyT(OtherBuckets[I].getFirst());
@@ -1229,7 +1222,8 @@ class DenseMapBase : public DebugEpochBase {
     assert((MinNumBuckets == 0 || isPowerOf2_32(MinNumBuckets)) &&
            "bucket count must be zero or a power of two");
     if constexpr (llvm::densemap::detail::isRelocatableBucket<BucketT>) {
-      Storage.grow(MinNumBuckets, hasher());
+      Storage.grow(MinNumBuckets,
+                   llvm::densemap::detail::hasherFor<KeyT, KeyInfoT>());
     } else {
       unsigned NumBuckets = StorageT::roundUpNumBuckets(MinNumBuckets);
       StorageT Tmp;
@@ -1254,7 +1248,7 @@ class DenseMapBase : public DebugEpochBase {
     unsigned NewNumEntries = getNumEntries() + 1;
     unsigned NumBuckets = getNumBuckets();
     if (LLVM_UNLIKELY(NewNumEntries * 4 >= NumBuckets * 3)) {
-      this->grow(NumBuckets * 2);
+      grow(NumBuckets * 2);
       LookupBucketFor(Lookup, TheBucket);
     }
     assert(TheBucket);

>From 6449d741041f9d04f54212bfe76919a7285449a3 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 4 Oct 2026 23:24:19 -0700
Subject: [PATCH 2/2] Address comments.

---
 llvm/include/llvm/ADT/DenseMap.h | 81 ++++++++++++++++----------------
 1 file changed, 40 insertions(+), 41 deletions(-)

diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h
index 806dc2fc3a9ce..773e7c2f0a486 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -316,36 +316,35 @@ template <typename BucketT, unsigned InlineBuckets> class SmallDenseMapStorage {
   union {
     InlineRep Inline;
     LargeRep Large;
-  } Storage;
+  } storage;
 
   const BucketT *getInlineBuckets() const {
     assert(Small);
     // Note that this cast does not violate aliasing rules as we assert that
     // the memory's dynamic type is the small, inline bucket buffer, and the
-    // 'Storage' is a POD containing a char buffer.
-    return reinterpret_cast<const BucketT *>(Storage.Inline.Buckets);
+    // 'storage' is a POD containing a char buffer.
+    return reinterpret_cast<const BucketT *>(storage.Inline.Buckets);
   }
 
   BucketT *getInlineBuckets() {
     assert(Small);
-    return reinterpret_cast<BucketT *>(Storage.Inline.Buckets);
+    return reinterpret_cast<BucketT *>(storage.Inline.Buckets);
   }
 
   const UsedT *getInlineUsed() const {
     assert(Small);
-    return Storage.Inline.Used;
+    return storage.Inline.Used;
   }
 
   UsedT *getInlineUsed() {
     assert(Small);
-    return Storage.Inline.Used;
+    return storage.Inline.Used;
   }
 
-  void setLarge(void *NewStorage, unsigned NumBuckets) {
+  void setLarge(void *Storage, unsigned NumBuckets) {
     Small = false;
-    Storage.Large = {static_cast<BucketT *>(NewStorage),
-                     usedFor(NewStorage, sizeof(BucketT), NumBuckets),
-                     NumBuckets};
+    storage.Large = {static_cast<BucketT *>(Storage),
+                     usedFor(Storage, sizeof(BucketT), NumBuckets), NumBuckets};
   }
 
 public:
@@ -358,7 +357,7 @@ template <typename BucketT, unsigned InlineBuckets> class SmallDenseMapStorage {
   }
 
   const BucketT *getBuckets() const {
-    return Small ? getInlineBuckets() : Storage.Large.Buckets;
+    return Small ? getInlineBuckets() : storage.Large.Buckets;
   }
 
   BucketT *getBuckets() {
@@ -367,7 +366,7 @@ template <typename BucketT, unsigned InlineBuckets> class SmallDenseMapStorage {
   }
 
   const UsedT *getUsed() const {
-    return Small ? getInlineUsed() : Storage.Large.Used;
+    return Small ? getInlineUsed() : storage.Large.Used;
   }
 
   UsedT *getUsed() {
@@ -376,14 +375,14 @@ template <typename BucketT, unsigned InlineBuckets> class SmallDenseMapStorage {
   }
 
   unsigned getNumBuckets() const {
-    return Small ? InlineBuckets : Storage.Large.NumBuckets;
+    return Small ? InlineBuckets : storage.Large.NumBuckets;
   }
 
   StorageRep<BucketT> getRep() const {
     if (Small)
       return {getInlineBuckets(), getInlineUsed(), InlineBuckets};
-    return {Storage.Large.Buckets, Storage.Large.Used,
-            Storage.Large.NumBuckets};
+    return {storage.Large.Buckets, storage.Large.Used,
+            storage.Large.NumBuckets};
   }
 
   void swap(SmallDenseMapStorage &RHS) {
@@ -418,7 +417,7 @@ template <typename BucketT, unsigned InlineBuckets> class SmallDenseMapStorage {
       return;
     }
     if (!Small && !RHS.Small) {
-      std::swap(Storage.Large, RHS.Storage.Large);
+      std::swap(storage.Large, RHS.storage.Large);
       return;
     }
 
@@ -428,7 +427,7 @@ template <typename BucketT, unsigned InlineBuckets> class SmallDenseMapStorage {
     // Stash the large rep, then move the small side's inline contents into the
     // large side (which becomes inline), and finally install the rep on the
     // small side (which becomes large).
-    LargeRep TmpRep = LargeSide.Storage.Large;
+    LargeRep TmpRep = LargeSide.storage.Large;
     LargeSide.Small = true;
     {
       UsedT *SU = SmallSide.getInlineUsed(), *LU = LargeSide.getInlineUsed();
@@ -441,32 +440,32 @@ template <typename BucketT, unsigned InlineBuckets> class SmallDenseMapStorage {
         LU[W] = SU[W];
     }
     SmallSide.Small = false;
-    SmallSide.Storage.Large = TmpRep;
+    SmallSide.storage.Large = TmpRep;
   }
 
   void grow(unsigned MinNumBuckets, BucketHasher Hasher) {
     unsigned NewNumBuckets = roundUpNumBuckets(MinNumBuckets);
     // remove_if asks for the count it already has: rehash in place.
     if (Small && NewNumBuckets <= InlineBuckets) {
-      InlineRep Old = Storage.Inline;
+      InlineRep Old = storage.Inline;
       clearUsed(getInlineUsed(), InlineBuckets);
       rehashRelocatable(getInlineBuckets(), getInlineUsed(), InlineBuckets,
                         Old.Buckets, Old.Used, InlineBuckets, sizeof(BucketT),
                         Hasher);
       return;
     }
-    void *NewStorage = growRelocatable(
+    void *Storage = growRelocatable(
         getBuckets(), getUsed(), getNumBuckets(), NewNumBuckets,
         sizeof(BucketT), allocAlign<BucketT>(), Hasher, /*FreeOld=*/!Small);
-    setLarge(NewStorage, NewNumBuckets);
+    setLarge(Storage, NewNumBuckets);
   }
 
   void deallocateBuckets() {
     if (Small)
       return;
 
-    deallocate_buffer(Storage.Large.Buckets,
-                      allocBytes<BucketT>(Storage.Large.NumBuckets),
+    deallocate_buffer(storage.Large.Buckets,
+                      allocBytes<BucketT>(storage.Large.NumBuckets),
                       allocAlign<BucketT>());
   }
 
@@ -497,7 +496,7 @@ template <typename BucketT, unsigned InlineBuckets> class SmallDenseMapStorage {
         NewNumBuckets = std::max(64u, NewNumBuckets);
     }
     bool Reuse = Small ? NewNumBuckets <= InlineBuckets
-                       : NewNumBuckets == Storage.Large.NumBuckets;
+                       : NewNumBuckets == storage.Large.NumBuckets;
     if (Reuse)
       return {false, 0};          // Reuse.
     return {true, NewNumBuckets}; // Reallocate.
@@ -509,7 +508,7 @@ template <typename BucketT, unsigned InlineBuckets> class SmallDenseMapStorage {
 
     Small = false;
     NumEntries = Other.NumEntries;
-    Storage.Large = Other.Storage.Large;
+    storage.Large = Other.storage.Large;
     return true;
   }
 };
@@ -621,9 +620,9 @@ class DenseMapIterator : DebugEpochBase::HandleBase {
   }
   DenseMapIterator operator++(int) { // Postincrement
     assert(isHandleInSync() && "invalid iterator access!");
-    DenseMapIterator Tmp = *this;
+    DenseMapIterator tmp = *this;
     ++*this;
-    return Tmp;
+    return tmp;
   }
 
 private:
@@ -990,9 +989,9 @@ class DenseMapBase : public DebugEpochBase {
         Storage, getMinBucketToReserveForEntries(NumElementsToReserve));
   }
 
-  DenseMapBase(const DenseMapBase &Other) : DenseMapBase() { copyFrom(Other); }
+  DenseMapBase(const DenseMapBase &other) : DenseMapBase() { copyFrom(other); }
 
-  DenseMapBase(DenseMapBase &&Other) : DenseMapBase() { swap(Other); }
+  DenseMapBase(DenseMapBase &&other) : DenseMapBase() { swap(other); }
 
   template <typename InputIt>
   DenseMapBase(const InputIt &I, const InputIt &E)
@@ -1012,17 +1011,17 @@ class DenseMapBase : public DebugEpochBase {
     Storage.deallocateBuckets();
   }
 
-  DenseMapBase &operator=(const DenseMapBase &Other) {
-    if (&Other != this)
-      copyFrom(Other);
+  DenseMapBase &operator=(const DenseMapBase &other) {
+    if (&other != this)
+      copyFrom(other);
     return *this;
   }
 
-  DenseMapBase &operator=(DenseMapBase &&Other) {
+  DenseMapBase &operator=(DenseMapBase &&other) {
     destroyAll();
     Storage.deallocateBuckets();
     initWithExactBucketCount(Storage, 0);
-    swap(Other);
+    swap(other);
     return *this;
   }
 
@@ -1107,25 +1106,25 @@ class DenseMapBase : public DebugEpochBase {
     Src.deallocateBuckets();
   }
 
-  LLVM_ATTRIBUTE_NOINLINE void copyFrom(const DenseMapBase &Other) {
+  LLVM_ATTRIBUTE_NOINLINE void copyFrom(const DenseMapBase &other) {
     destroyAll();
     Storage.deallocateBuckets();
     setNumEntries(0);
-    if (!Storage.allocateBuckets(Other.getNumBuckets())) {
+    if (!Storage.allocateBuckets(other.getNumBuckets())) {
       // The bucket list is empty.  No work to do.
       return;
     }
 
-    assert(&Other != this);
-    assert(getNumBuckets() == Other.getNumBuckets());
+    assert(&other != this);
+    assert(getNumBuckets() == other.getNumBuckets());
 
-    setNumEntries(Other.getNumEntries());
+    setNumEntries(other.getNumEntries());
 
     BucketT *Buckets = getBuckets();
-    const BucketT *OtherBuckets = Other.getBuckets();
+    const BucketT *OtherBuckets = other.getBuckets();
     const unsigned NumBuckets = getNumBuckets();
     UsedT *U = getUsed();
-    const UsedT *OtherU = Other.getUsed();
+    const UsedT *OtherU = other.getUsed();
     std::memcpy(U, OtherU,
                 llvm::densemap::detail::usedWords(NumBuckets) * sizeof(UsedT));
     if constexpr (densemap::detail::isRelocatableBucket<BucketT>) {



More information about the llvm-commits mailing list