From e3f87943291d589059a9f2838e5dbb05bc91d7dd Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Mon, 3 Feb 2014 11:24:18 +0000 Subject: Rename the non-templated base class of SmallPtrSet to 'SmallPtrSetImplBase'. This more closely matches the organization of SmallVector and should allow introducing a SmallPtrSetImpl which serves the same purpose as SmallVectorImpl: isolating the element type from the particular small size chosen. This in turn allows a lot of simplification of APIs by not coding them against a specific small size which is rarely needed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200687 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/SmallPtrSet.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'lib/Support/SmallPtrSet.cpp') diff --git a/lib/Support/SmallPtrSet.cpp b/lib/Support/SmallPtrSet.cpp index f873d91d6e..f7b8a7723c 100644 --- a/lib/Support/SmallPtrSet.cpp +++ b/lib/Support/SmallPtrSet.cpp @@ -20,7 +20,7 @@ using namespace llvm; -void SmallPtrSetImpl::shrink_and_clear() { +void SmallPtrSetImplBase::shrink_and_clear() { assert(!isSmall() && "Can't shrink a small set!"); free(CurArray); @@ -34,7 +34,7 @@ void SmallPtrSetImpl::shrink_and_clear() { memset(CurArray, -1, CurArraySize*sizeof(void*)); } -bool SmallPtrSetImpl::insert_imp(const void * Ptr) { +bool SmallPtrSetImplBase::insert_imp(const void * Ptr) { if (isSmall()) { // Check to see if it is already in the set. for (const void **APtr = SmallArray, **E = SmallArray+NumElements; @@ -71,7 +71,7 @@ bool SmallPtrSetImpl::insert_imp(const void * Ptr) { return true; } -bool SmallPtrSetImpl::erase_imp(const void * Ptr) { +bool SmallPtrSetImplBase::erase_imp(const void * Ptr) { if (isSmall()) { // Check to see if it is in the set. for (const void **APtr = SmallArray, **E = SmallArray+NumElements; @@ -98,7 +98,7 @@ bool SmallPtrSetImpl::erase_imp(const void * Ptr) { return true; } -const void * const *SmallPtrSetImpl::FindBucketFor(const void *Ptr) const { +const void * const *SmallPtrSetImplBase::FindBucketFor(const void *Ptr) const { unsigned Bucket = DenseMapInfo::getHashValue(Ptr) & (CurArraySize-1); unsigned ArraySize = CurArraySize; unsigned ProbeAmt = 1; @@ -127,7 +127,7 @@ const void * const *SmallPtrSetImpl::FindBucketFor(const void *Ptr) const { /// Grow - Allocate a larger backing store for the buckets and move it over. /// -void SmallPtrSetImpl::Grow(unsigned NewSize) { +void SmallPtrSetImplBase::Grow(unsigned NewSize) { // Allocate at twice as many buckets, but at least 128. unsigned OldSize = CurArraySize; @@ -163,8 +163,8 @@ void SmallPtrSetImpl::Grow(unsigned NewSize) { } } -SmallPtrSetImpl::SmallPtrSetImpl(const void **SmallStorage, - const SmallPtrSetImpl& that) { +SmallPtrSetImplBase::SmallPtrSetImplBase(const void **SmallStorage, + const SmallPtrSetImplBase& that) { SmallArray = SmallStorage; // If we're becoming small, prepare to insert into our stack space @@ -187,8 +187,9 @@ SmallPtrSetImpl::SmallPtrSetImpl(const void **SmallStorage, } #if LLVM_HAS_RVALUE_REFERENCES -SmallPtrSetImpl::SmallPtrSetImpl(const void **SmallStorage, unsigned SmallSize, - SmallPtrSetImpl &&that) { +SmallPtrSetImplBase::SmallPtrSetImplBase(const void **SmallStorage, + unsigned SmallSize, + SmallPtrSetImplBase &&that) { SmallArray = SmallStorage; // Copy over the basic members. @@ -217,7 +218,7 @@ SmallPtrSetImpl::SmallPtrSetImpl(const void **SmallStorage, unsigned SmallSize, /// CopyFrom - implement operator= from a smallptrset that has the same pointer /// type, but may have a different small size. -void SmallPtrSetImpl::CopyFrom(const SmallPtrSetImpl &RHS) { +void SmallPtrSetImplBase::CopyFrom(const SmallPtrSetImplBase &RHS) { assert(&RHS != this && "Self-copy should be handled by the caller."); if (isSmall() && RHS.isSmall()) @@ -254,7 +255,8 @@ void SmallPtrSetImpl::CopyFrom(const SmallPtrSetImpl &RHS) { } #if LLVM_HAS_RVALUE_REFERENCES -void SmallPtrSetImpl::MoveFrom(unsigned SmallSize, SmallPtrSetImpl &&RHS) { +void SmallPtrSetImplBase::MoveFrom(unsigned SmallSize, + SmallPtrSetImplBase &&RHS) { assert(&RHS != this && "Self-move should be handled by the caller."); if (!isSmall()) @@ -282,7 +284,7 @@ void SmallPtrSetImpl::MoveFrom(unsigned SmallSize, SmallPtrSetImpl &&RHS) { } #endif -void SmallPtrSetImpl::swap(SmallPtrSetImpl &RHS) { +void SmallPtrSetImplBase::swap(SmallPtrSetImplBase &RHS) { if (this == &RHS) return; // We can only avoid copying elements if neither set is small. @@ -332,7 +334,7 @@ void SmallPtrSetImpl::swap(SmallPtrSetImpl &RHS) { std::swap(this->NumElements, RHS.NumElements); } -SmallPtrSetImpl::~SmallPtrSetImpl() { +SmallPtrSetImplBase::~SmallPtrSetImplBase() { if (!isSmall()) free(CurArray); } -- cgit v1.2.3