]> granicus.if.org Git - clang/commitdiff
Make sure to deallocate the identifier lookup tables and selector tables
authorDouglas Gregor <dgregor@apple.com>
Thu, 19 Aug 2010 00:28:17 +0000 (00:28 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 19 Aug 2010 00:28:17 +0000 (00:28 +0000)
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

include/clang/Serialization/ASTReader.h
lib/Serialization/ASTReader.cpp

index 41d64b8b0de68a9c333ec072b27714613572c57e..d4a0ea9f48cd5e73461f6e19507e2dc5d952ee5c 100644 (file)
@@ -198,6 +198,7 @@ private:
   /// \brief Information that is needed for every file in the chain.
   struct PerFileData {
     PerFileData();
+    ~PerFileData();
 
     /// \brief The AST stat cache installed for this file, if any.
     ///
index eade7650791fe437dee09eb2799b01984e4b48e9..fb26851e3a3e59f2e716bbd023a5e7c51f9d6a7a 100644 (file)
@@ -448,15 +448,6 @@ ASTReader::~ASTReader() {
     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 @@ void ASTReader::FinishedDeserializing() {
   }
   --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);
+}
+