summaryrefslogtreecommitdiff
path: root/lib/VMCore/LLVMContextImpl.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2011-07-12 00:26:08 +0000
committerNick Lewycky <nicholas@mxc.ca>2011-07-12 00:26:08 +0000
commit1852e217019507c6329ee3af227dc05c6e517878 (patch)
treee5e27c201f55d9af13c937e4340e0cbbfcab6ef1 /lib/VMCore/LLVMContextImpl.cpp
parent1a54bb28c79d5fc5b1c4e7fb0273ccb6a92c74e0 (diff)
downloadllvm-1852e217019507c6329ee3af227dc05c6e517878.tar.gz
llvm-1852e217019507c6329ee3af227dc05c6e517878.tar.bz2
llvm-1852e217019507c6329ee3af227dc05c6e517878.tar.xz
TypeMap had a destructor that destroyed the types it held. DenseMap did not, so
destroy those types in ~LLVMContext. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134945 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/LLVMContextImpl.cpp')
-rw-r--r--lib/VMCore/LLVMContextImpl.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/lib/VMCore/LLVMContextImpl.cpp b/lib/VMCore/LLVMContextImpl.cpp
index 0b7ae6c927..12cb2464b5 100644
--- a/lib/VMCore/LLVMContextImpl.cpp
+++ b/lib/VMCore/LLVMContextImpl.cpp
@@ -13,6 +13,7 @@
#include "LLVMContextImpl.h"
#include "llvm/Module.h"
+#include "llvm/ADT/STLExtras.h"
#include <algorithm>
using namespace llvm;
@@ -54,9 +55,7 @@ LLVMContextImpl::~LLVMContextImpl() {
// will try to remove itself from OwnedModules set. This would cause
// iterator invalidation if we iterated on the set directly.
std::vector<Module*> Modules(OwnedModules.begin(), OwnedModules.end());
- for (std::vector<Module*>::iterator I = Modules.begin(), E = Modules.end();
- I != E; ++I)
- delete *I;
+ DeleteContainerPointers(Modules);
std::for_each(ExprConstants.map_begin(), ExprConstants.map_end(),
DropReferences());
@@ -74,14 +73,8 @@ LLVMContextImpl::~LLVMContextImpl() {
NullPtrConstants.freeConstants();
UndefValueConstants.freeConstants();
InlineAsms.freeConstants();
- for (IntMapTy::iterator I = IntConstants.begin(), E = IntConstants.end();
- I != E; ++I) {
- delete I->second;
- }
- for (FPMapTy::iterator I = FPConstants.begin(), E = FPConstants.end();
- I != E; ++I) {
- delete I->second;
- }
+ DeleteContainerSeconds(IntConstants);
+ DeleteContainerSeconds(FPConstants);
// Destroy MDNodes. ~MDNode can move and remove nodes between the MDNodeSet
// and the NonUniquedMDNodes sets, so copy the values out first.
@@ -99,7 +92,18 @@ LLVMContextImpl::~LLVMContextImpl() {
assert(MDNodeSet.empty() && NonUniquedMDNodes.empty() &&
"Destroying all MDNodes didn't empty the Context's sets.");
// Destroy MDStrings.
- for (StringMap<MDString*>::iterator I = MDStringCache.begin(),
- E = MDStringCache.end(); I != E; ++I)
- delete I->second;
+ DeleteContainerSeconds(MDStringCache);
+
+ // Destroy types.
+ DeleteContainerSeconds(IntegerTypes);
+ DeleteContainerSeconds(FunctionTypes);
+ DeleteContainerSeconds(AnonStructTypes);
+ DeleteContainerSeconds(ArrayTypes);
+ DeleteContainerSeconds(VectorTypes);
+ DeleteContainerSeconds(PointerTypes);
+ DeleteContainerSeconds(ASPointerTypes);
+
+ for (StringMap<StructType *>::iterator I = NamedStructTypes.begin(), E = NamedStructTypes.end(); I != E; ++I) {
+ delete I->getValue();
+ }
}