aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore/LLVMContextImpl.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-07-13 04:22:39 +0000
committerChris Lattner <sabre@nondot.org>2011-07-13 04:22:39 +0000
commitc09ef37171b2a6c914ce34928a4ff4a839b21dbe (patch)
treecf3a291fa985da8d813e8e8806279397f933c43f /lib/VMCore/LLVMContextImpl.cpp
parent3b737081e49ef7d640d50285b6cb5f686c75f63d (diff)
stop leaking all named struct types with an empty name. Thanks
to Benjamin Kramer for steering me in the right direction here. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135031 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/LLVMContextImpl.cpp')
-rw-r--r--lib/VMCore/LLVMContextImpl.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/VMCore/LLVMContextImpl.cpp b/lib/VMCore/LLVMContextImpl.cpp
index 12cb2464b5..2b6bb39167 100644
--- a/lib/VMCore/LLVMContextImpl.cpp
+++ b/lib/VMCore/LLVMContextImpl.cpp
@@ -81,14 +81,12 @@ LLVMContextImpl::~LLVMContextImpl() {
SmallVector<MDNode*, 8> MDNodes;
MDNodes.reserve(MDNodeSet.size() + NonUniquedMDNodes.size());
for (FoldingSetIterator<MDNode> I = MDNodeSet.begin(), E = MDNodeSet.end();
- I != E; ++I) {
+ I != E; ++I)
MDNodes.push_back(&*I);
- }
MDNodes.append(NonUniquedMDNodes.begin(), NonUniquedMDNodes.end());
for (SmallVectorImpl<MDNode *>::iterator I = MDNodes.begin(),
- E = MDNodes.end(); I != E; ++I) {
+ E = MDNodes.end(); I != E; ++I)
(*I)->destroy();
- }
assert(MDNodeSet.empty() && NonUniquedMDNodes.empty() &&
"Destroying all MDNodes didn't empty the Context's sets.");
// Destroy MDStrings.
@@ -103,7 +101,10 @@ LLVMContextImpl::~LLVMContextImpl() {
DeleteContainerSeconds(PointerTypes);
DeleteContainerSeconds(ASPointerTypes);
- for (StringMap<StructType *>::iterator I = NamedStructTypes.begin(), E = NamedStructTypes.end(); I != E; ++I) {
+ for (StringMap<StructType *>::iterator I = NamedStructTypes.begin(),
+ E = NamedStructTypes.end(); I != E; ++I)
delete I->getValue();
- }
+ for (SmallPtrSet<StructType*, 16>::iterator I = EmptyNamedStructTypes.begin(),
+ E = EmptyNamedStructTypes.end(); I != E; ++I)
+ delete *I;
}