diff --git a/include/llvm/ADT/FoldingSet.h b/include/llvm/ADT/FoldingSet.h index 7ade1678178..278e43e3e74 100644 --- a/include/llvm/ADT/FoldingSet.h +++ b/include/llvm/ADT/FoldingSet.h @@ -110,6 +110,8 @@ class FoldingSetNodeID; /// back to the bucket to facilitate node removal. /// class FoldingSetImpl { + virtual void anchor(); // Out of line virtual method. + protected: /// Buckets - Array of bucket chains. /// @@ -123,10 +125,11 @@ protected: /// is greater than twice the number of buckets. unsigned NumNodes; -public: - explicit FoldingSetImpl(unsigned Log2InitSize = 6); - virtual ~FoldingSetImpl(); + ~FoldingSetImpl(); + explicit FoldingSetImpl(unsigned Log2InitSize = 6); + +public: //===--------------------------------------------------------------------===// /// Node - This class is used to maintain the singly linked bucket list in /// a folding set. @@ -393,7 +396,7 @@ DefaultContextualFoldingSetTrait::ComputeHash(T &X, /// implementation of the folding set to the node class T. T must be a /// subclass of FoldingSetNode and implement a Profile function. /// -template class FoldingSet : public FoldingSetImpl { +template class FoldingSet final : public FoldingSetImpl { private: /// GetNodeProfile - Each instantiatation of the FoldingSet needs to provide a /// way to convert nodes into a unique specifier. @@ -463,7 +466,7 @@ public: /// function with signature /// void Profile(llvm::FoldingSetNodeID &, Ctx); template -class ContextualFoldingSet : public FoldingSetImpl { +class ContextualFoldingSet final : public FoldingSetImpl { // Unfortunately, this can't derive from FoldingSet because the // construction vtable for FoldingSet requires // FoldingSet::GetNodeProfile to be instantiated, which in turn diff --git a/lib/Support/FoldingSet.cpp b/lib/Support/FoldingSet.cpp index 0bee31510f7..80d2aefe870 100644 --- a/lib/Support/FoldingSet.cpp +++ b/lib/Support/FoldingSet.cpp @@ -223,6 +223,8 @@ static void **AllocateBuckets(unsigned NumBuckets) { //===----------------------------------------------------------------------===// // FoldingSetImpl Implementation +void FoldingSetImpl::anchor() {} + FoldingSetImpl::FoldingSetImpl(unsigned Log2InitSize) { assert(5 < Log2InitSize && Log2InitSize < 32 && "Initial hash table size out of range");