[llvm] [ADT] Fix formatting in FoldingSet.* (NFC) (PR #216591)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 16 16:08:44 PDT 2026


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

>From 8f74bcffb6757b7ae776877c4a055fea78f53f1f Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 16 Aug 2026 11:10:15 -0700
Subject: [PATCH 1/2] [ADT] Fix formatting in FoldingSet.* (NFC)

I'm planning to work on FoldingSet.
---
 llvm/include/llvm/ADT/FoldingSet.h | 126 +++++++++++++----------------
 llvm/lib/Support/FoldingSet.cpp    |  78 ++++++++++--------
 llvm/unittests/ADT/FoldingSet.cpp  |   5 +-
 3 files changed, 101 insertions(+), 108 deletions(-)

diff --git a/llvm/include/llvm/ADT/FoldingSet.h b/llvm/include/llvm/ADT/FoldingSet.h
index 8a62bb411397d..b46aa10732a93 100644
--- a/llvm/include/llvm/ADT/FoldingSet.h
+++ b/llvm/include/llvm/ADT/FoldingSet.h
@@ -113,13 +113,9 @@ class StringRef;
 
 /// This class provides default implementations for FoldingSetTrait
 /// implementations.
-template<typename T> struct DefaultFoldingSetTrait {
-  static void Profile(const T &X, FoldingSetNodeID &ID) {
-    X.Profile(ID);
-  }
-  static void Profile(T &X, FoldingSetNodeID &ID) {
-    X.Profile(ID);
-  }
+template <typename T> struct DefaultFoldingSetTrait {
+  static void Profile(const T &X, FoldingSetNodeID &ID) { X.Profile(ID); }
+  static void Profile(T &X, FoldingSetNodeID &ID) { X.Profile(ID); }
 
   // Equals - Test if the profile for X would match ID, using TempID
   // to compute a temporary ID if necessary. The default implementation
@@ -146,8 +142,7 @@ template <typename T, typename Enable = void>
 struct FoldingSetTrait : public DefaultFoldingSetTrait<T> {};
 
 /// Like DefaultFoldingSetTrait, but for ContextualFoldingSets.
-template<typename T, typename Ctx>
-struct DefaultContextualFoldingSetTrait {
+template <typename T, typename Ctx> struct DefaultContextualFoldingSetTrait {
   static void Profile(T &X, FoldingSetNodeID &ID, Ctx Context) {
     X.Profile(ID, Context);
   }
@@ -159,8 +154,9 @@ struct DefaultContextualFoldingSetTrait {
 };
 
 /// Like FoldingSetTrait, but for ContextualFoldingSets.
-template<typename T, typename Ctx> struct ContextualFoldingSetTrait
-  : public DefaultContextualFoldingSetTrait<T, Ctx> {};
+template <typename T, typename Ctx>
+struct ContextualFoldingSetTrait
+    : public DefaultContextualFoldingSetTrait<T, Ctx> {};
 
 //===--------------------------------------------------------------------===//
 /// This class describes a reference to an interned FoldingSetNodeID, which can
@@ -222,7 +218,7 @@ class FoldingSetNodeID {
   FoldingSetNodeID() = default;
 
   FoldingSetNodeID(FoldingSetNodeIDRef Ref)
-    : Bits(Ref.getData(), Ref.getData() + Ref.getSize()) {}
+      : Bits(Ref.getData(), Ref.getData() + Ref.getSize()) {}
 
   /// Add* - Add various data types to Bit data.
   void AddPointer(const void *Ptr) {
@@ -244,8 +240,9 @@ class FoldingSetNodeID {
   LLVM_ABI void AddString(StringRef String);
   LLVM_ABI void AddNodeID(const FoldingSetNodeID &ID);
 
-  template <typename T>
-  inline void Add(const T &x) { FoldingSetTrait<T>::Profile(x, *this); }
+  template <typename T> inline void Add(const T &x) {
+    FoldingSetTrait<T>::Profile(x, *this);
+  }
 
   /// Clear the accumulated profile, allowing this FoldingSetNodeID
   /// object to be used to compute a new profile.
@@ -269,7 +266,9 @@ class FoldingSetNodeID {
   LLVM_ABI bool operator==(const FoldingSetNodeIDRef RHS) const;
 
   bool operator!=(const FoldingSetNodeID &RHS) const { return !(*this == RHS); }
-  bool operator!=(const FoldingSetNodeIDRef RHS) const { return !(*this ==RHS);}
+  bool operator!=(const FoldingSetNodeIDRef RHS) const {
+    return !(*this == RHS);
+  }
 
   /// Used to compare the "ordering" of two nodes as defined by the
   /// profiled bits and their ordering defined by memcmp().
@@ -406,35 +405,29 @@ template <class T> class FoldingSetIterator;
 
 // Definitions of FoldingSetTrait and ContextualFoldingSetTrait functions, which
 // require the definition of FoldingSetNodeID.
-template<typename T>
-inline bool
-DefaultFoldingSetTrait<T>::Equals(T &X, const FoldingSetNodeID &ID,
-                                  unsigned /*IDHash*/,
-                                  FoldingSetNodeID &TempID) {
+template <typename T>
+inline bool DefaultFoldingSetTrait<T>::Equals(T &X, const FoldingSetNodeID &ID,
+                                              unsigned /*IDHash*/,
+                                              FoldingSetNodeID &TempID) {
   FoldingSetTrait<T>::Profile(X, TempID);
   return TempID == ID;
 }
-template<typename T>
+template <typename T>
 inline unsigned
 DefaultFoldingSetTrait<T>::ComputeHash(T &X, FoldingSetNodeID &TempID) {
   FoldingSetTrait<T>::Profile(X, TempID);
   return TempID.ComputeHash();
 }
-template<typename T, typename Ctx>
-inline bool
-DefaultContextualFoldingSetTrait<T, Ctx>::Equals(T &X,
-                                                 const FoldingSetNodeID &ID,
-                                                 unsigned /*IDHash*/,
-                                                 FoldingSetNodeID &TempID,
-                                                 Ctx Context) {
+template <typename T, typename Ctx>
+inline bool DefaultContextualFoldingSetTrait<T, Ctx>::Equals(
+    T &X, const FoldingSetNodeID &ID, unsigned /*IDHash*/,
+    FoldingSetNodeID &TempID, Ctx Context) {
   ContextualFoldingSetTrait<T, Ctx>::Profile(X, TempID, Context);
   return TempID == ID;
 }
-template<typename T, typename Ctx>
-inline unsigned
-DefaultContextualFoldingSetTrait<T, Ctx>::ComputeHash(T &X,
-                                                      FoldingSetNodeID &TempID,
-                                                      Ctx Context) {
+template <typename T, typename Ctx>
+inline unsigned DefaultContextualFoldingSetTrait<T, Ctx>::ComputeHash(
+    T &X, FoldingSetNodeID &TempID, Ctx Context) {
   ContextualFoldingSetTrait<T, Ctx>::Profile(X, TempID, Context);
   return TempID.ComputeHash();
 }
@@ -455,12 +448,12 @@ template <class Derived, class T> class FoldingSetImpl : public FoldingSetBase {
   using iterator = FoldingSetIterator<T>;
 
   iterator begin() { return iterator(Buckets); }
-  iterator end() { return iterator(Buckets+NumBuckets); }
+  iterator end() { return iterator(Buckets + NumBuckets); }
 
   using const_iterator = FoldingSetIterator<const T>;
 
   const_iterator begin() const { return const_iterator(Buckets); }
-  const_iterator end() const { return const_iterator(Buckets+NumBuckets); }
+  const_iterator end() const { return const_iterator(Buckets + NumBuckets); }
 
   /// Increase the number of buckets such that adding the \p EltCount th node
   /// won't cause a rebucket operation. reserve is permitted to allocate more
@@ -471,9 +464,7 @@ template <class Derived, class T> class FoldingSetImpl : public FoldingSetBase {
 
   /// Remove a node from the folding set, returning true if one
   /// was removed or false if the node was not in the folding set.
-  bool RemoveNode(T *N) {
-    return FoldingSetBase::RemoveNode(N);
-  }
+  bool RemoveNode(T *N) { return FoldingSetBase::RemoveNode(N); }
 
   /// If there is an existing simple Node exactly equal to the specified node,
   /// return it.  Otherwise, insert 'N' and return it instead.
@@ -514,8 +505,7 @@ template <class Derived, class T> class FoldingSetImpl : public FoldingSetBase {
 /// moved-from state is not a valid state for anything other than
 /// move-assigning and destroying. This is primarily to enable movable APIs
 /// that incorporate these objects.
-template <class T>
-class FoldingSet : public FoldingSetImpl<FoldingSet<T>, T> {
+template <class T> class FoldingSet : public FoldingSetImpl<FoldingSet<T>, T> {
   using Super = FoldingSetImpl<FoldingSet, T>;
   using Node = typename Super::Node;
 
@@ -579,7 +569,7 @@ class ContextualFoldingSet
   Ctx Context;
 
   static const Ctx &getContext(const FoldingSetBase *Base) {
-    return static_cast<const ContextualFoldingSet*>(Base)->Context;
+    return static_cast<const ContextualFoldingSet *>(Base)->Context;
   }
 
   /// Each instantiatation of the FoldingSet needs to provide a way to convert
@@ -624,8 +614,7 @@ class ContextualFoldingSet
 /// interface of FoldingSet but with deterministic iteration order based on the
 /// insertion order. T must be a subclass of FoldingSetNode and implement a
 /// Profile function.
-template <class T, class VectorT = SmallVector<T*, 8>>
-class FoldingSetVector {
+template <class T, class VectorT = SmallVector<T *, 8>> class FoldingSetVector {
   FoldingSet<T> Set;
   VectorT Vector;
 
@@ -635,15 +624,18 @@ class FoldingSetVector {
   using iterator = pointee_iterator<typename VectorT::iterator>;
 
   iterator begin() { return Vector.begin(); }
-  iterator end()   { return Vector.end(); }
+  iterator end() { return Vector.end(); }
 
   using const_iterator = pointee_iterator<typename VectorT::const_iterator>;
 
   const_iterator begin() const { return Vector.begin(); }
-  const_iterator end()   const { return Vector.end(); }
+  const_iterator end() const { return Vector.end(); }
 
   /// Remove all nodes from the folding set.
-  void clear() { Set.clear(); Vector.clear(); }
+  void clear() {
+    Set.clear();
+    Vector.clear();
+  }
 
   /// Look up the node specified by ID.  If it exists, return it.  If not,
   /// return the insertion token that will make insertion faster.
@@ -655,7 +647,8 @@ class FoldingSetVector {
   /// return it.  Otherwise, insert 'N' and return it instead.
   T *GetOrInsertNode(T *N) {
     T *Result = Set.GetOrInsertNode(N);
-    if (Result == N) Vector.push_back(N);
+    if (Result == N)
+      Vector.push_back(N);
     return Result;
   }
 
@@ -705,33 +698,30 @@ template <class T> class FoldingSetIterator : public FoldingSetIteratorImpl {
 public:
   explicit FoldingSetIterator(void **Bucket) : FoldingSetIteratorImpl(Bucket) {}
 
-  T &operator*() const {
-    return *static_cast<T*>(NodePtr);
-  }
+  T &operator*() const { return *static_cast<T *>(NodePtr); }
 
-  T *operator->() const {
-    return static_cast<T*>(NodePtr);
-  }
+  T *operator->() const { return static_cast<T *>(NodePtr); }
 
-  inline FoldingSetIterator &operator++() {          // Preincrement
+  inline FoldingSetIterator &operator++() { // Preincrement
     advance();
     return *this;
   }
-  FoldingSetIterator operator++(int) {        // Postincrement
-    FoldingSetIterator tmp = *this; ++*this; return tmp;
+  FoldingSetIterator operator++(int) { // Postincrement
+    FoldingSetIterator tmp = *this;
+    ++*this;
+    return tmp;
   }
 };
 
 //===----------------------------------------------------------------------===//
 /// This template class is used to "wrap" arbitrary types in an enclosing object
 /// so that they can be inserted into FoldingSets.
-template <typename T>
-class FoldingSetNodeWrapper : public FoldingSetNode {
+template <typename T> class FoldingSetNodeWrapper : public FoldingSetNode {
   T data;
 
 public:
   template <typename... Ts>
-  explicit FoldingSetNodeWrapper(Ts &&... Args)
+  explicit FoldingSetNodeWrapper(Ts &&...Args)
       : data(std::forward<Ts>(Args)...) {}
 
   void Profile(FoldingSetNodeID &ID) { FoldingSetTrait<T>::Profile(data, ID); }
@@ -739,8 +729,8 @@ class FoldingSetNodeWrapper : public FoldingSetNode {
   T &getValue() { return data; }
   const T &getValue() const { return data; }
 
-  operator T&() { return data; }
-  operator const T&() const { return data; }
+  operator T &() { return data; }
+  operator const T &() const { return data; }
 };
 
 //===----------------------------------------------------------------------===//
@@ -762,15 +752,11 @@ class FastFoldingSetNode : public FoldingSetNode {
 //===----------------------------------------------------------------------===//
 // Partial specializations of FoldingSetTrait.
 
-template<typename T> struct FoldingSetTrait<T*> {
-  static inline void Profile(T *X, FoldingSetNodeID &ID) {
-    ID.AddPointer(X);
-  }
+template <typename T> struct FoldingSetTrait<T *> {
+  static inline void Profile(T *X, FoldingSetNodeID &ID) { ID.AddPointer(X); }
 };
-template <typename T1, typename T2>
-struct FoldingSetTrait<std::pair<T1, T2>> {
-  static inline void Profile(const std::pair<T1, T2> &P,
-                             FoldingSetNodeID &ID) {
+template <typename T1, typename T2> struct FoldingSetTrait<std::pair<T1, T2>> {
+  static inline void Profile(const std::pair<T1, T2> &P, FoldingSetNodeID &ID) {
     ID.Add(P.first);
     ID.Add(P.second);
   }
@@ -783,6 +769,6 @@ struct FoldingSetTrait<T, std::enable_if_t<std::is_enum<T>::value>> {
   }
 };
 
-} // end namespace llvm
+} // namespace llvm
 
 #endif // LLVM_ADT_FOLDINGSET_H
diff --git a/llvm/lib/Support/FoldingSet.cpp b/llvm/lib/Support/FoldingSet.cpp
index c8c732f852beb..ab85d0539ced3 100644
--- a/llvm/lib/Support/FoldingSet.cpp
+++ b/llvm/lib/Support/FoldingSet.cpp
@@ -26,8 +26,9 @@ using namespace llvm;
 // FoldingSetNodeIDRef Implementation
 
 bool FoldingSetNodeIDRef::operator==(FoldingSetNodeIDRef RHS) const {
-  if (Size != RHS.Size) return false;
-  return memcmp(Data, RHS.Data, Size*sizeof(*Data)) == 0;
+  if (Size != RHS.Size)
+    return false;
+  return memcmp(Data, RHS.Data, Size * sizeof(*Data)) == 0;
 }
 
 /// Used to compare the "ordering" of two nodes as defined by the
@@ -35,7 +36,7 @@ bool FoldingSetNodeIDRef::operator==(FoldingSetNodeIDRef RHS) const {
 bool FoldingSetNodeIDRef::operator<(FoldingSetNodeIDRef RHS) const {
   if (Size != RHS.Size)
     return Size < RHS.Size;
-  return memcmp(Data, RHS.Data, Size*sizeof(*Data)) < 0;
+  return memcmp(Data, RHS.Data, Size * sizeof(*Data)) < 0;
 }
 
 //===----------------------------------------------------------------------===//
@@ -44,17 +45,18 @@ bool FoldingSetNodeIDRef::operator<(FoldingSetNodeIDRef RHS) const {
 /// Add* - Add various data types to Bit data.
 ///
 void FoldingSetNodeID::AddString(StringRef String) {
-  unsigned Size =  String.size();
+  unsigned Size = String.size();
 
   unsigned NumInserts = 1 + divideCeil(Size, 4);
   Bits.reserve(Bits.size() + NumInserts);
 
   Bits.push_back(Size);
-  if (!Size) return;
+  if (!Size)
+    return;
 
   unsigned Units = Size / 4;
   unsigned Pos = 0;
-  const unsigned *Base = (const unsigned*) String.data();
+  const unsigned *Base = (const unsigned *)String.data();
 
   // If the string is aligned do a bulk transfer.
   if (!((intptr_t)Base & 3)) {
@@ -71,15 +73,15 @@ void FoldingSetNodeID::AddString(StringRef String) {
         unsigned V = ((unsigned char)String[Pos - 4] << 24) |
                      ((unsigned char)String[Pos - 3] << 16) |
                      ((unsigned char)String[Pos - 2] << 8) |
-                      (unsigned char)String[Pos - 1];
+                     (unsigned char)String[Pos - 1];
         Bits.push_back(V);
       }
-    } else {  // Little-endian host
+    } else { // Little-endian host
       for (Pos += 4; Pos <= Size; Pos += 4) {
         unsigned V = ((unsigned char)String[Pos - 1] << 24) |
                      ((unsigned char)String[Pos - 2] << 16) |
                      ((unsigned char)String[Pos - 3] << 8) |
-                      (unsigned char)String[Pos - 4];
+                     (unsigned char)String[Pos - 4];
         Bits.push_back(V);
       }
     }
@@ -90,10 +92,17 @@ void FoldingSetNodeID::AddString(StringRef String) {
   // Pos will have overshot size by 4 - #bytes left over.
   // No need to take endianness into account here - this is always executed.
   switch (Pos - Size) {
-  case 1: V = (V << 8) | (unsigned char)String[Size - 3]; [[fallthrough]];
-  case 2: V = (V << 8) | (unsigned char)String[Size - 2]; [[fallthrough]];
-  case 3: V = (V << 8) | (unsigned char)String[Size - 1]; break;
-  default: return; // Nothing left.
+  case 1:
+    V = (V << 8) | (unsigned char)String[Size - 3];
+    [[fallthrough]];
+  case 2:
+    V = (V << 8) | (unsigned char)String[Size - 2];
+    [[fallthrough]];
+  case 3:
+    V = (V << 8) | (unsigned char)String[Size - 1];
+    break;
+  default:
+    return; // Nothing left.
   }
 
   Bits.push_back(V);
@@ -150,31 +159,30 @@ static FoldingSetBase::Node *GetNextPtr(void *NextInBucketPtr) {
   if (reinterpret_cast<intptr_t>(NextInBucketPtr) & 1)
     return nullptr;
 
-  return static_cast<FoldingSetBase::Node*>(NextInBucketPtr);
+  return static_cast<FoldingSetBase::Node *>(NextInBucketPtr);
 }
 
-
 /// testing.
 static void **GetBucketPtr(void *NextInBucketPtr) {
   intptr_t Ptr = reinterpret_cast<intptr_t>(NextInBucketPtr);
   assert((Ptr & 1) && "Not a bucket pointer");
-  return reinterpret_cast<void**>(Ptr & ~intptr_t(1));
+  return reinterpret_cast<void **>(Ptr & ~intptr_t(1));
 }
 
 /// GetBucketFor - Hash the specified node ID and return the hash bucket for
 /// the specified ID.
 static void **GetBucketFor(unsigned Hash, void **Buckets, unsigned NumBuckets) {
   // NumBuckets is always a power of 2.
-  unsigned BucketNum = Hash & (NumBuckets-1);
+  unsigned BucketNum = Hash & (NumBuckets - 1);
   return Buckets + BucketNum;
 }
 
 /// AllocateBuckets - Allocated initialized bucket memory.
 static void **AllocateBuckets(unsigned NumBuckets) {
-  void **Buckets = static_cast<void**>(safe_calloc(NumBuckets + 1,
-                                                   sizeof(void*)));
+  void **Buckets =
+      static_cast<void **>(safe_calloc(NumBuckets + 1, sizeof(void *)));
   // Set the very last bucket to be a non-null "pointer".
-  Buckets[NumBuckets] = reinterpret_cast<void*>(-1);
+  Buckets[NumBuckets] = reinterpret_cast<void *>(-1);
   return Buckets;
 }
 
@@ -207,16 +215,14 @@ FoldingSetBase &FoldingSetBase::operator=(FoldingSetBase &&RHS) {
   return *this;
 }
 
-FoldingSetBase::~FoldingSetBase() {
-  free(Buckets);
-}
+FoldingSetBase::~FoldingSetBase() { free(Buckets); }
 
 void FoldingSetBase::clear() {
   // Set all but the last bucket to null pointers.
-  memset(Buckets, 0, NumBuckets*sizeof(void*));
+  memset(Buckets, 0, NumBuckets * sizeof(void *));
 
   // Set the very last bucket to be a non-null "pointer".
-  Buckets[NumBuckets] = reinterpret_cast<void*>(-1);
+  Buckets[NumBuckets] = reinterpret_cast<void *>(-1);
 
   // Reset the node count to zero.
   NumNodes = 0;
@@ -240,7 +246,8 @@ void FoldingSetBase::GrowBucketCount(unsigned NewBucketCount,
   FoldingSetNodeID TempID;
   for (unsigned i = 0; i != OldNumBuckets; ++i) {
     void *Probe = OldBuckets[i];
-    if (!Probe) continue;
+    if (!Probe)
+      continue;
     while (Node *NodeInBucket = GetNextPtr(Probe)) {
       // Figure out the next link, remove NodeInBucket from the old link.
       Probe = NodeInBucket->getNextInBucket();
@@ -268,7 +275,7 @@ void FoldingSetBase::reserve(unsigned EltCount, const FoldingSetInfo &Info) {
   // This will give us somewhere between EltCount / 2 and
   // EltCount buckets.  This puts us in the load factor
   // range of 1.0 - 2.0.
-  if(EltCount < capacity())
+  if (EltCount < capacity())
     return;
   GrowBucketCount(llvm::bit_floor(EltCount), Info);
 }
@@ -305,7 +312,7 @@ void FoldingSetBase::InsertNode(Node *N, void *InsertPos,
                                 const FoldingSetInfo &Info) {
   assert(!N->getNextInBucket());
   // Do we need to grow the hashtable?
-  if (NumNodes+1 > capacity()) {
+  if (NumNodes + 1 > capacity()) {
     GrowHashTable(Info);
     FoldingSetNodeID TempID;
     InsertPos = GetBucketFor(Info.ComputeNodeHash(this, N, TempID), Buckets,
@@ -315,7 +322,7 @@ void FoldingSetBase::InsertNode(Node *N, void *InsertPos,
   ++NumNodes;
 
   /// The insert position is actually a bucket pointer.
-  void **Bucket = static_cast<void**>(InsertPos);
+  void **Bucket = static_cast<void **>(InsertPos);
 
   void *Next = *Bucket;
 
@@ -323,7 +330,7 @@ void FoldingSetBase::InsertNode(Node *N, void *InsertPos,
   // null.  Pretend as if it pointed to itself, setting the low bit to indicate
   // that it is a pointer to the bucket.
   if (!Next)
-    Next = reinterpret_cast<void*>(reinterpret_cast<intptr_t>(Bucket)|1);
+    Next = reinterpret_cast<void *>(reinterpret_cast<intptr_t>(Bucket) | 1);
 
   // Set the node's next pointer, and make the bucket point to the node.
   N->SetNextInBucket(Next);
@@ -336,7 +343,8 @@ bool FoldingSetBase::RemoveNode(Node *N) {
   // Because each bucket is a circular list, we don't need to compute N's hash
   // to remove it.
   void *Ptr = N->getNextInBucket();
-  if (!Ptr) return false;  // Not in folding set.
+  if (!Ptr)
+    return false; // Not in folding set.
 
   --NumNodes;
   N->SetNextInBucket(nullptr);
@@ -390,11 +398,11 @@ FoldingSetBase::GetOrInsertNode(FoldingSetBase::Node *N,
 
 FoldingSetIteratorImpl::FoldingSetIteratorImpl(void **Bucket) {
   // Skip to the first non-null non-self-cycle bucket.
-  while (*Bucket != reinterpret_cast<void*>(-1) &&
+  while (*Bucket != reinterpret_cast<void *>(-1) &&
          (!*Bucket || !GetNextPtr(*Bucket)))
     ++Bucket;
 
-  NodePtr = static_cast<FoldingSetNode*>(*Bucket);
+  NodePtr = static_cast<FoldingSetNode *>(*Bucket);
 }
 
 void FoldingSetIteratorImpl::advance() {
@@ -410,9 +418,9 @@ void FoldingSetIteratorImpl::advance() {
     // Skip to the next non-null non-self-cycle bucket.
     do {
       ++Bucket;
-    } while (*Bucket != reinterpret_cast<void*>(-1) &&
+    } while (*Bucket != reinterpret_cast<void *>(-1) &&
              (!*Bucket || !GetNextPtr(*Bucket)));
 
-    NodePtr = static_cast<FoldingSetNode*>(*Bucket);
+    NodePtr = static_cast<FoldingSetNode *>(*Bucket);
   }
 }
diff --git a/llvm/unittests/ADT/FoldingSet.cpp b/llvm/unittests/ADT/FoldingSet.cpp
index c03353f4e4b07..0101c85667202 100644
--- a/llvm/unittests/ADT/FoldingSet.cpp
+++ b/llvm/unittests/ADT/FoldingSet.cpp
@@ -24,7 +24,7 @@ TEST(FoldingSetTest, UnalignedStringTest) {
 
   FoldingSetNodeID a, b;
   // An aligned string.
-  std::string str1= "a test string";
+  std::string str1 = "a test string";
   a.AddString(str1);
 
   // An unaligned string.
@@ -188,5 +188,4 @@ TEST(FoldingSetTest, SmallReserveChangesNothing) {
   EXPECT_EQ(Trivial.capacity(), OldCapacity);
 }
 
-}
-
+} // namespace

>From 3b0aed30e9d1e0be0154229de08613fbbe26d511 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 16 Aug 2026 16:08:21 -0700
Subject: [PATCH 2/2] Address comments.

---
 llvm/include/llvm/ADT/FoldingSet.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/include/llvm/ADT/FoldingSet.h b/llvm/include/llvm/ADT/FoldingSet.h
index b46aa10732a93..72edc3aac21fb 100644
--- a/llvm/include/llvm/ADT/FoldingSet.h
+++ b/llvm/include/llvm/ADT/FoldingSet.h
@@ -155,8 +155,7 @@ template <typename T, typename Ctx> struct DefaultContextualFoldingSetTrait {
 
 /// Like FoldingSetTrait, but for ContextualFoldingSets.
 template <typename T, typename Ctx>
-struct ContextualFoldingSetTrait
-    : public DefaultContextualFoldingSetTrait<T, Ctx> {};
+struct ContextualFoldingSetTrait : DefaultContextualFoldingSetTrait<T, Ctx> {};
 
 //===--------------------------------------------------------------------===//
 /// This class describes a reference to an interned FoldingSetNodeID, which can



More information about the llvm-commits mailing list