Make sure to deallocate the identifier lookup tables and selector tables
when destroying an ASTReader. Plugs a leak that shows up in libclang.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111488 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp
index eade765..fb26851 100644
--- a/lib/Serialization/ASTReader.cpp
+++ b/lib/Serialization/ASTReader.cpp
@@ -448,15 +448,6 @@
delete Chain[e - i - 1];
}
-ASTReader::PerFileData::PerFileData()
- : StatCache(0), LocalNumSLocEntries(0), LocalNumTypes(0), TypeOffsets(0),
- LocalNumDecls(0), DeclOffsets(0), LocalNumIdentifiers(0),
- IdentifierOffsets(0), IdentifierTableData(0), IdentifierLookupTable(0),
- LocalNumMacroDefinitions(0), MacroDefinitionOffsets(0),
- NumPreallocatedPreprocessingEntities(0), SelectorLookupTable(0),
- SelectorLookupTableData(0), SelectorOffsets(0), LocalNumSelectors(0)
-{}
-
void
ASTReader::setDeserializationListener(ASTDeserializationListener *Listener) {
DeserializationListener = Listener;
@@ -3838,3 +3829,18 @@
}
--NumCurrentElementsDeserializing;
}
+
+ASTReader::PerFileData::PerFileData()
+ : StatCache(0), LocalNumSLocEntries(0), LocalNumTypes(0), TypeOffsets(0),
+ LocalNumDecls(0), DeclOffsets(0), LocalNumIdentifiers(0),
+ IdentifierOffsets(0), IdentifierTableData(0), IdentifierLookupTable(0),
+ LocalNumMacroDefinitions(0), MacroDefinitionOffsets(0),
+ NumPreallocatedPreprocessingEntities(0), SelectorLookupTable(0),
+ SelectorLookupTableData(0), SelectorOffsets(0), LocalNumSelectors(0)
+{}
+
+ASTReader::PerFileData::~PerFileData() {
+ delete static_cast<ASTIdentifierLookupTable *>(IdentifierLookupTable);
+ delete static_cast<ASTSelectorLookupTable *>(SelectorLookupTable);
+}
+