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:
parent
86346ede95
commit
14b2993484
|
@ -31,21 +31,18 @@ enum { BasicMetadataBlock = 1,
|
|||
DeclsBlock = 3 };
|
||||
|
||||
TranslationUnit::~TranslationUnit() {
|
||||
|
||||
llvm::DenseSet<Decl*> Killed;
|
||||
|
||||
for (iterator I=begin(), E=end(); I!=E; ++I) {
|
||||
if (Killed.count(*I)) continue;
|
||||
|
||||
Killed.insert(*I);
|
||||
(*I)->Destroy(*Context);
|
||||
}
|
||||
|
||||
if (OwnsMetaData && Context) {
|
||||
llvm::DenseSet<Decl*> Killed;
|
||||
for (iterator I=begin(), E=end(); I!=E; ++I) {
|
||||
if (Killed.count(*I)) continue;
|
||||
|
||||
Killed.insert(*I);
|
||||
(*I)->Destroy(*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);
|
||||
|
|
Loading…
Reference in New Issue