diff options
author | Chris Lattner <sabre@nondot.org> | 2009-02-20 22:19:20 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-02-20 22:19:20 +0000 |
commit | 0301b3ff132a4d986c092d161cb77d74b04cd2a6 (patch) | |
tree | 0bac38518640027c357530d5344af3bc8e09a0da /lib/Lex | |
parent | 9f4ecb34d502f6aad7d635dd3aec24a373ef5c9b (diff) |
require the MAcroInfo objects are explcitly destroyed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65179 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex')
-rw-r--r-- | lib/Lex/PPDirectives.cpp | 14 | ||||
-rw-r--r-- | lib/Lex/Preprocessor.cpp | 1 |
2 files changed, 12 insertions, 3 deletions
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index c38310b925..5a100995b8 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/lib/Lex/PPDirectives.cpp @@ -24,18 +24,26 @@ using namespace clang; // Utility Methods for Preprocessor Directive Handling. //===----------------------------------------------------------------------===// -MacroInfo* Preprocessor::AllocateMacroInfo(SourceLocation L) { +MacroInfo *Preprocessor::AllocateMacroInfo(SourceLocation L) { MacroInfo *MI; if (!MICache.empty()) { MI = MICache.back(); MICache.pop_back(); - } - else MI = (MacroInfo*) BP.Allocate<MacroInfo>(); + } else + MI = (MacroInfo*) BP.Allocate<MacroInfo>(); new (MI) MacroInfo(L); return MI; } +/// ReleaseMacroInfo - Release the specified MacroInfo. This memory will +/// be reused for allocating new MacroInfo objects. +void Preprocessor::ReleaseMacroInfo(MacroInfo* MI) { + MICache.push_back(MI); + MI->Destroy(); +} + + /// DiscardUntilEndOfDirective - Read and discard all tokens remaining on the /// current line until the tok::eom token is found. void Preprocessor::DiscardUntilEndOfDirective() { diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index 31a040674f..7b34cb65e3 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -101,6 +101,7 @@ Preprocessor::~Preprocessor() { // will be released when the BumpPtrAllocator 'BP' object gets // destroyed. We still need to run the dstor, however, to free // memory alocated by MacroInfo. + I->second->Destroy(); I->second->~MacroInfo(); I->first->setHasMacroDefinition(false); } |