diff options
author | Torok Edwin <edwintorok@gmail.com> | 2009-04-06 20:49:21 +0000 |
---|---|---|
committer | Torok Edwin <edwintorok@gmail.com> | 2009-04-06 20:49:21 +0000 |
commit | 59d5f83b32753b3c9d5defa4d1374f7c9042eb46 (patch) | |
tree | eb8b8953a818130db853bbad7f1b7338034d73ad /lib | |
parent | 63c3ffc16ae0dd6254b43e8a90e319df6e8b2440 (diff) |
fix (part of) memory leak on shutdown. See PR2975.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68457 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/VMCore/Type.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index c14d5119e5..f0ee04ae24 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -666,6 +666,22 @@ protected: std::multimap<unsigned, PATypeHolder> TypesByHash; public: + ~TypeMapBase() + { + for (std::multimap<unsigned, PATypeHolder>::iterator I + = TypesByHash.begin(), E = TypesByHash.end(); I != E;) { + Type *Ty = I->second.get(); + if (!Ty->isAbstract() && (isa<PointerType>(Ty) || isa<FunctionType>(Ty) || + isa<VectorType>(Ty))) { + TypesByHash.erase(I++); + // PATypeHolder won't destroy it, so we must + Ty->destroy(); + } + else + ++I; + } + } + void RemoveFromTypesByHash(unsigned Hash, const Type *Ty) { std::multimap<unsigned, PATypeHolder>::iterator I = TypesByHash.lower_bound(Hash); |