summaryrefslogtreecommitdiff
path: root/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
commit3549f3cf197ea18f0d2b19206fbd18798c2fa972 (patch)
treed53a24b0c599fbb77c7012b41e9e6e2b69ec2d6a /lib/IR/PassRegistry.cpp
parent9bc7c0707d12cd92fa1d7b44476d70c547c6291b (diff)
downloadllvm-3549f3cf197ea18f0d2b19206fbd18798c2fa972.tar.gz
llvm-3549f3cf197ea18f0d2b19206fbd18798c2fa972.tar.bz2
llvm-3549f3cf197ea18f0d2b19206fbd18798c2fa972.tar.xz
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
Diffstat (limited to 'lib/IR/PassRegistry.cpp')
-rw-r--r--lib/IR/PassRegistry.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/IR/PassRegistry.cpp b/lib/IR/PassRegistry.cpp
index 89f4f60f05..6a5bee2f57 100644
--- a/lib/IR/PassRegistry.cpp
+++ b/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) {