summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/PassRegistry.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-04-15 15:17:14 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-04-15 15:17:14 +0000
commit0afad5e8bc02d143994ba35809ae14028a43c573 (patch)
tree0f16c4f2b5160d0bc2b0f20ff1d6af9539b3f0e0 /llvm/lib/IR/PassRegistry.cpp
parentc801b4a2aa94ab9570505c51a480c8fed975aa70 (diff)
downloadbcm5719-llvm-0afad5e8bc02d143994ba35809ae14028a43c573.tar.gz
bcm5719-llvm-0afad5e8bc02d143994ba35809ae14028a43c573.zip
Use unique_ptr to manage PassInfo instances in the PassRegistry
llvm-svn: 206297
Diffstat (limited to 'llvm/lib/IR/PassRegistry.cpp')
-rw-r--r--llvm/lib/IR/PassRegistry.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/llvm/lib/IR/PassRegistry.cpp b/llvm/lib/IR/PassRegistry.cpp
index 89f4f60f054..6a5bee2f57b 100644
--- a/llvm/lib/IR/PassRegistry.cpp
+++ b/llvm/lib/IR/PassRegistry.cpp
@@ -57,7 +57,7 @@ struct PassRegistryImpl {
};
DenseMap<const PassInfo*, AnalysisGroupInfo> AnalysisGroupInfoMap;
- std::vector<const PassInfo*> ToFree;
+ std::vector<std::unique_ptr<const PassInfo>> ToFree;
std::vector<PassRegistrationListener*> Listeners;
};
} // end anonymous namespace
@@ -75,11 +75,6 @@ void *PassRegistry::getImpl() const {
PassRegistry::~PassRegistry() {
sys::SmartScopedWriter<true> Guard(*Lock);
PassRegistryImpl *Impl = static_cast<PassRegistryImpl*>(pImpl);
-
- for (std::vector<const PassInfo*>::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<const PassInfo>(&PI));
}
void PassRegistry::unregisterPass(const PassInfo &PI) {
@@ -185,7 +180,8 @@ void PassRegistry::registerAnalysisGroup(const void *InterfaceID,
}
PassRegistryImpl *Impl = static_cast<PassRegistryImpl*>(getImpl());
- if (ShouldFree) Impl->ToFree.push_back(&Registeree);
+ if (ShouldFree)
+ Impl->ToFree.push_back(std::unique_ptr<const PassInfo>(&Registeree));
}
void PassRegistry::addRegistrationListener(PassRegistrationListener *L) {
OpenPOWER on IntegriCloud