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
This commit is contained in:
Nick Lewycky 2011-07-12 00:26:08 +00:00
parent 1a54bb28c7
commit 1852e21701

View File

@ -13,6 +13,7 @@
#include "LLVMContextImpl.h" #include "LLVMContextImpl.h"
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/ADT/STLExtras.h"
#include <algorithm> #include <algorithm>
using namespace llvm; using namespace llvm;
@ -54,9 +55,7 @@ LLVMContextImpl::~LLVMContextImpl() {
// will try to remove itself from OwnedModules set. This would cause // will try to remove itself from OwnedModules set. This would cause
// iterator invalidation if we iterated on the set directly. // iterator invalidation if we iterated on the set directly.
std::vector<Module*> Modules(OwnedModules.begin(), OwnedModules.end()); std::vector<Module*> Modules(OwnedModules.begin(), OwnedModules.end());
for (std::vector<Module*>::iterator I = Modules.begin(), E = Modules.end(); DeleteContainerPointers(Modules);
I != E; ++I)
delete *I;
std::for_each(ExprConstants.map_begin(), ExprConstants.map_end(), std::for_each(ExprConstants.map_begin(), ExprConstants.map_end(),
DropReferences()); DropReferences());
@ -74,14 +73,8 @@ LLVMContextImpl::~LLVMContextImpl() {
NullPtrConstants.freeConstants(); NullPtrConstants.freeConstants();
UndefValueConstants.freeConstants(); UndefValueConstants.freeConstants();
InlineAsms.freeConstants(); InlineAsms.freeConstants();
for (IntMapTy::iterator I = IntConstants.begin(), E = IntConstants.end(); DeleteContainerSeconds(IntConstants);
I != E; ++I) { DeleteContainerSeconds(FPConstants);
delete I->second;
}
for (FPMapTy::iterator I = FPConstants.begin(), E = FPConstants.end();
I != E; ++I) {
delete I->second;
}
// Destroy MDNodes. ~MDNode can move and remove nodes between the MDNodeSet // Destroy MDNodes. ~MDNode can move and remove nodes between the MDNodeSet
// and the NonUniquedMDNodes sets, so copy the values out first. // and the NonUniquedMDNodes sets, so copy the values out first.
@ -99,7 +92,18 @@ LLVMContextImpl::~LLVMContextImpl() {
assert(MDNodeSet.empty() && NonUniquedMDNodes.empty() && assert(MDNodeSet.empty() && NonUniquedMDNodes.empty() &&
"Destroying all MDNodes didn't empty the Context's sets."); "Destroying all MDNodes didn't empty the Context's sets.");
// Destroy MDStrings. // Destroy MDStrings.
for (StringMap<MDString*>::iterator I = MDStringCache.begin(), DeleteContainerSeconds(MDStringCache);
E = MDStringCache.end(); I != E; ++I)
delete I->second; // 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();
}
} }