From: David Blaikie Date: Tue, 15 Apr 2014 15:17:14 +0000 (+0000) Subject: Use unique_ptr to manage PassInfo instances in the PassRegistry X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3549f3cf197ea18f0d2b19206fbd18798c2fa972;p=oota-llvm.git Use unique_ptr to manage PassInfo instances in the PassRegistry git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206297 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/IR/PassRegistry.cpp b/lib/IR/PassRegistry.cpp index 89f4f60f054..6a5bee2f57b 100644 --- a/lib/IR/PassRegistry.cpp +++ b/lib/IR/PassRegistry.cpp @@ -57,7 +57,7 @@ struct PassRegistryImpl { }; DenseMap AnalysisGroupInfoMap; - std::vector ToFree; + std::vector> ToFree; std::vector Listeners; }; } // end anonymous namespace @@ -75,11 +75,6 @@ void *PassRegistry::getImpl() const { PassRegistry::~PassRegistry() { sys::SmartScopedWriter Guard(*Lock); PassRegistryImpl *Impl = static_cast(pImpl); - - for (std::vector::iterator I = Impl->ToFree.begin(), - E = Impl->ToFree.end(); I != E; ++I) - delete *I; - delete Impl; pImpl = nullptr; } @@ -117,7 +112,7 @@ void PassRegistry::registerPass(const PassInfo &PI, bool ShouldFree) { I = Impl->Listeners.begin(), E = Impl->Listeners.end(); I != E; ++I) (*I)->passRegistered(&PI); - if (ShouldFree) Impl->ToFree.push_back(&PI); + if (ShouldFree) Impl->ToFree.push_back(std::unique_ptr(&PI)); } void PassRegistry::unregisterPass(const PassInfo &PI) { @@ -185,7 +180,8 @@ void PassRegistry::registerAnalysisGroup(const void *InterfaceID, } PassRegistryImpl *Impl = static_cast(getImpl()); - if (ShouldFree) Impl->ToFree.push_back(&Registeree); + if (ShouldFree) + Impl->ToFree.push_back(std::unique_ptr(&Registeree)); } void PassRegistry::addRegistrationListener(PassRegistrationListener *L) {