aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-06-08 23:00:53 +0000
committerTed Kremenek <kremenek@apple.com>2010-06-08 23:00:53 +0000
commit83c1a6fb4126f080387de2a97cddefe458188106 (patch)
treed74ae63a8113730d2c9681fa644c3d54b2b591f9
parent3104124fdad54f1935abc8f867b76caf75c2d533 (diff)
Fix memory leak in Preprocessor where MacroInfo objects in the MICache wouldn't have their
associated SmallVectors get deallocated. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105658 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Lex/Preprocessor.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp
index ce6d9ab5c0..c20ecef47b 100644
--- a/lib/Lex/Preprocessor.cpp
+++ b/lib/Lex/Preprocessor.cpp
@@ -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)