diff options
| author | Torok Edwin <edwintorok@gmail.com> | 2009-04-07 17:23:02 +0000 |
|---|---|---|
| committer | Torok Edwin <edwintorok@gmail.com> | 2009-04-07 17:23:02 +0000 |
| commit | 73312b3f395f47b64786ec44b868fe0230545803 (patch) | |
| tree | ae15ac2ecdc36d48e0c019eab9d7418aea716937 /llvm/lib | |
| parent | b1fe2c90016197752ca86bf8ef18086dcf2cf96c (diff) | |
| download | bcm5719-llvm-73312b3f395f47b64786ec44b868fe0230545803.tar.gz bcm5719-llvm-73312b3f395f47b64786ec44b868fe0230545803.zip | |
Another attempt at fixing PR2975.
Types can have references to eachother, so we can't just call destroy on them.
llvm-svn: 68523
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/VMCore/Type.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Type.cpp b/llvm/lib/VMCore/Type.cpp index c14d5119e5d..9f93d17d9f3 100644 --- a/llvm/lib/VMCore/Type.cpp +++ b/llvm/lib/VMCore/Type.cpp @@ -388,6 +388,10 @@ OpaqueType::OpaqueType() : DerivedType(OpaqueTyID) { #endif } +void PATypeHolder::destroy() { + Ty = 0; +} + // dropAllTypeUses - When this (abstract) type is resolved to be equal to // another (more concrete) type, we must eliminate all references to other // types, to avoid some circular reference problems. @@ -666,6 +670,27 @@ protected: std::multimap<unsigned, PATypeHolder> TypesByHash; public: + ~TypeMapBase() + { + //PATypeHolder won't destroy non-abstract types. + //We can't destroy them by simply iterating, because + //they may contain references to each-other + + for (std::multimap<unsigned, PATypeHolder>::iterator I + = TypesByHash.begin(), E = TypesByHash.end(); I != E; ++I) { + Type *Ty = const_cast<Type*>(I->second.Ty); + I->second.destroy(); + // We can't invoke destroy or delete, because the type may + // contain references to already freed types. + // So we have to destruct the object the ugly way. + if (Ty) { + Ty->AbstractTypeUsers.clear(); + static_cast<const Type*>(Ty)->Type::~Type(); + operator delete(Ty); + } + } + } + void RemoveFromTypesByHash(unsigned Hash, const Type *Ty) { std::multimap<unsigned, PATypeHolder>::iterator I = TypesByHash.lower_bound(Hash); |

