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 | 666f7a42d6b5753f9d55d4cb1f1a3a48cb49cd9a (patch) | |
| tree | d01767ac6ecc0f1e5fc4c63dd735e5e2fba57b82 /clang/lib | |
| parent | 8a9481d50df49c773fca5178e8d34a6512a62e64 (diff) | |
| download | bcm5719-llvm-666f7a42d6b5753f9d55d4cb1f1a3a48cb49cd9a.tar.gz bcm5719-llvm-666f7a42d6b5753f9d55d4cb1f1a3a48cb49cd9a.zip | |
require the MAcroInfo objects are explcitly destroyed.
llvm-svn: 65179
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Lex/PPDirectives.cpp | 14 | ||||
| -rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 1 |
2 files changed, 12 insertions, 3 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index c38310b925f..5a100995b8a 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/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/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index 31a040674f7..7b34cb65e36 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/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); } |

