diff options
-rw-r--r-- | lib/Lex/PPDirectives.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index ffdc6ae589..9138af064f 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/lib/Lex/PPDirectives.cpp @@ -37,7 +37,7 @@ MacroInfo *Preprocessor::AllocateMacroInfo() { MacroInfoChain *MIChain = BP.Allocate<MacroInfoChain>(); MIChain->Next = MIChainHead; MIChainHead = MIChain; - MI = &(MIChainHead->MI); + MI = &(MIChain->MI); } return MI; } @@ -58,7 +58,11 @@ MacroInfo *Preprocessor::CloneMacroInfo(const MacroInfo &MacroToClone) { /// be reused for allocating new MacroInfo objects. void Preprocessor::ReleaseMacroInfo(MacroInfo *MI) { MICache.push_back(MI); - MI->FreeArgumentList(); + // We need to call 'Destroy' as opposed to 'FreeArgumentList' because + // the MICache object will get reused with a placement new. This does + // not cause the underlying SmallVector to get it's memory released, so + // we need to call Destroy() here. + MI->Destroy(); } |