FoldingSet: Make FoldingSetImpl's dtor protected and non-virtual

It's not intended to be polymorphically deleted. Make FoldingSet
and ContextualFoldingSet final to avoid noise from -Wnon-virtual-dtor.

No functional change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232922 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Benjamin Kramer 2015-03-22 18:22:33 +00:00
parent 031fbaeb29
commit 00edfaecf0
2 changed files with 10 additions and 5 deletions

View File

@ -110,6 +110,8 @@ class FoldingSetNodeID;
/// back to the bucket to facilitate node removal. /// back to the bucket to facilitate node removal.
/// ///
class FoldingSetImpl { class FoldingSetImpl {
virtual void anchor(); // Out of line virtual method.
protected: protected:
/// Buckets - Array of bucket chains. /// Buckets - Array of bucket chains.
/// ///
@ -123,10 +125,11 @@ protected:
/// is greater than twice the number of buckets. /// is greater than twice the number of buckets.
unsigned NumNodes; unsigned NumNodes;
public: ~FoldingSetImpl();
explicit FoldingSetImpl(unsigned Log2InitSize = 6);
virtual ~FoldingSetImpl();
explicit FoldingSetImpl(unsigned Log2InitSize = 6);
public:
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
/// Node - This class is used to maintain the singly linked bucket list in /// Node - This class is used to maintain the singly linked bucket list in
/// a folding set. /// a folding set.
@ -393,7 +396,7 @@ DefaultContextualFoldingSetTrait<T, Ctx>::ComputeHash(T &X,
/// implementation of the folding set to the node class T. T must be a /// implementation of the folding set to the node class T. T must be a
/// subclass of FoldingSetNode and implement a Profile function. /// subclass of FoldingSetNode and implement a Profile function.
/// ///
template<class T> class FoldingSet : public FoldingSetImpl { template <class T> class FoldingSet final : public FoldingSetImpl {
private: private:
/// GetNodeProfile - Each instantiatation of the FoldingSet needs to provide a /// GetNodeProfile - Each instantiatation of the FoldingSet needs to provide a
/// way to convert nodes into a unique specifier. /// way to convert nodes into a unique specifier.
@ -463,7 +466,7 @@ public:
/// function with signature /// function with signature
/// void Profile(llvm::FoldingSetNodeID &, Ctx); /// void Profile(llvm::FoldingSetNodeID &, Ctx);
template <class T, class Ctx> template <class T, class Ctx>
class ContextualFoldingSet : public FoldingSetImpl { class ContextualFoldingSet final : public FoldingSetImpl {
// Unfortunately, this can't derive from FoldingSet<T> because the // Unfortunately, this can't derive from FoldingSet<T> because the
// construction vtable for FoldingSet<T> requires // construction vtable for FoldingSet<T> requires
// FoldingSet<T>::GetNodeProfile to be instantiated, which in turn // FoldingSet<T>::GetNodeProfile to be instantiated, which in turn

View File

@ -223,6 +223,8 @@ static void **AllocateBuckets(unsigned NumBuckets) {
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// FoldingSetImpl Implementation // FoldingSetImpl Implementation
void FoldingSetImpl::anchor() {}
FoldingSetImpl::FoldingSetImpl(unsigned Log2InitSize) { FoldingSetImpl::FoldingSetImpl(unsigned Log2InitSize) {
assert(5 < Log2InitSize && Log2InitSize < 32 && assert(5 < Log2InitSize && Log2InitSize < 32 &&
"Initial hash table size out of range"); "Initial hash table size out of range");