[cfe-commits] r105658 - /cfe/trunk/lib/Lex/Preprocessor.cpp

Ted Kremenek kremenek at apple.com
Tue Jun 8 16:00:53 PDT 2010


Author: kremenek
Date: Tue Jun  8 18:00:53 2010
New Revision: 105658

URL: http://llvm.org/viewvc/llvm-project?rev=105658&view=rev
Log:
Fix memory leak in Preprocessor where MacroInfo objects in the MICache wouldn't have their
associated SmallVectors get deallocated.

Modified:
    cfe/trunk/lib/Lex/Preprocessor.cpp

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=105658&r1=105657&r2=105658&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Tue Jun  8 18:00:53 2010
@@ -113,6 +113,14 @@
     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)





More information about the cfe-commits mailing list