LLVM 19.0.0git
FoldingSet.cpp File Reference
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/SwapByteOrder.h"
#include <cassert>
#include <cstring>

Go to the source code of this file.


static FoldingSetBase::NodeGetNextPtr (void *NextInBucketPtr)
 Helper functions for FoldingSetBase.
static void ** GetBucketPtr (void *NextInBucketPtr)
static void ** GetBucketFor (unsigned Hash, void **Buckets, unsigned NumBuckets)
 GetBucketFor - Hash the specified node ID and return the hash bucket for the specified ID.
static void ** AllocateBuckets (unsigned NumBuckets)
 AllocateBuckets - Allocated initialized bucket memory.

Function Documentation

◆ AllocateBuckets()

static void ** AllocateBuckets ( unsigned  NumBuckets)

AllocateBuckets - Allocated initialized bucket memory.

Definition at line 172 of file FoldingSet.cpp.

References llvm::safe_calloc().

Referenced by llvm::FoldingSetBase::FoldingSetBase().

◆ GetBucketFor()

static void ** GetBucketFor ( unsigned  Hash,
void **  Buckets,
unsigned  NumBuckets 

GetBucketFor - Hash the specified node ID and return the hash bucket for the specified ID.

Definition at line 165 of file FoldingSet.cpp.

Referenced by llvm::FoldingSetBase::FindNodeOrInsertPos(), and llvm::FoldingSetBase::InsertNode().

◆ GetBucketPtr()

static void ** GetBucketPtr ( void *  NextInBucketPtr)


Definition at line 157 of file FoldingSet.cpp.

References assert(), and Ptr.

Referenced by llvm::FoldingSetIteratorImpl::advance(), and llvm::FoldingSetBase::RemoveNode().

◆ GetNextPtr()

static FoldingSetBase::Node * GetNextPtr ( void *  NextInBucketPtr)

Helper functions for FoldingSetBase.

GetNextPtr - In order to save space, each bucket is a singly-linked-list. In order to make deletion more efficient, we make the list circular, so we can delete a node without computing its hash. The problem with this is that the start of the hash buckets are not Nodes. If NextInBucketPtr is a bucket pointer, this method returns null: use GetBucketPtr when this happens.

Definition at line 147 of file FoldingSet.cpp.

Referenced by llvm::FoldingSetIteratorImpl::advance(), llvm::FoldingSetBase::FindNodeOrInsertPos(), llvm::FoldingSetBucketIteratorImpl::FoldingSetBucketIteratorImpl(), llvm::FoldingSetIteratorImpl::FoldingSetIteratorImpl(), and llvm::FoldingSetBase::RemoveNode().