Don't kill the declarations if the translation unit doesn't own them

(specifically, for TranslationUnits created from SerializationTest.cpp).  
Fixes a double-free bug in the serialization tests.

llvm-svn: 51362
This commit is contained in:
Eli Friedman 2008-05-21 05:01:55 +00:00
parent 86346ede95
commit 14b2993484
1 changed files with 8 additions and 11 deletions

View File

@ -31,9 +31,8 @@ enum { BasicMetadataBlock = 1,
DeclsBlock = 3 };
TranslationUnit::~TranslationUnit() {
if (OwnsMetaData && Context) {
llvm::DenseSet<Decl*> Killed;
for (iterator I=begin(), E=end(); I!=E; ++I) {
if (Killed.count(*I)) continue;
@ -41,11 +40,9 @@ TranslationUnit::~TranslationUnit() {
(*I)->Destroy(*Context);
}
if (OwnsMetaData && Context) {
// The ASTContext object has the sole references to the IdentifierTable
// Selectors, and the Target information. Go and delete them, since
// the TranslationUnit effectively owns them.
delete &(Context->Idents);
delete &(Context->Selectors);
delete &(Context->Target);