]> granicus.if.org Git - clang/commitdiff
Fix memory leak in Preprocessor where MacroInfo objects in the MICache wouldn't have...
authorTed Kremenek <kremenek@apple.com>
Tue, 8 Jun 2010 23:00:53 +0000 (23:00 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 8 Jun 2010 23:00:53 +0000 (23:00 +0000)
associated SmallVectors get deallocated.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105658 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/Preprocessor.cpp

index ce6d9ab5c0539ca2384525a4e2ba4ebd81978c05..c20ecef47bdc3eda024230db11654854bf91a87a 100644 (file)
@@ -113,6 +113,14 @@ Preprocessor::~Preprocessor() {
     I->second->Destroy(BP);
     I->first->setHasMacroDefinition(false);
   }
+  for (std::vector<MacroInfo*>::iterator I = MICache.begin(),
+                                         E = MICache.end(); I != E; ++I) {
+    // We don't need to free the MacroInfo objects directly.  These
+    // will be released when the BumpPtrAllocator 'BP' object gets
+    // destroyed.  We still need to run the dtor, however, to free
+    // memory alocated by MacroInfo.
+    (*I)->Destroy(BP);
+  }
 
   // Free any cached macro expanders.
   for (unsigned i = 0, e = NumCachedTokenLexers; i != e; ++i)