require the MAcroInfo objects are explcitly destroyed.

llvm-svn: 65179
This commit is contained in:
Chris Lattner 2009-02-20 22:19:20 +00:00
parent 8a9481d50d
commit 666f7a42d6
4 changed files with 18 additions and 6 deletions

View File

@ -76,7 +76,12 @@ public:
MacroInfo(SourceLocation DefLoc);
~MacroInfo() {
assert(ArgumentList == 0 && "Didn't call destroy before dtor!");
}
void Destroy() {
delete[] ArgumentList;
ArgumentList = 0;
}
/// getDefinitionLoc - Return the location that the macro was defined at.

View File

@ -579,9 +579,7 @@ private:
/// ReleaseMacroInfo - Release the specified MacroInfo. This memory will
/// be reused for allocating new MacroInfo objects.
void ReleaseMacroInfo(MacroInfo* MI) {
MICache.push_back(MI);
}
void ReleaseMacroInfo(MacroInfo* MI);
/// isInPrimaryFile - Return true if we're in the top-level file, not in a
/// #include.

View File

@ -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() {

View File

@ -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);
}