diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-04-30 05:05:35 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-04-30 05:05:35 +0000 |
commit | d48b91dbbe63e60e214c62d8cda4d20bc3347015 (patch) | |
tree | 6d987c8afd3aa8d84f3cd350250f1771e23e8186 /clang/lib/Lex/PPDirectives.cpp | |
parent | 95012aaa9371fe1b6dd95749753d75eb6ed1ac20 (diff) | |
download | bcm5719-llvm-d48b91dbbe63e60e214c62d8cda4d20bc3347015.tar.gz bcm5719-llvm-d48b91dbbe63e60e214c62d8cda4d20bc3347015.zip |
[PCH] Fix memory leak related to deserialized MacroInfo objects.
Deserialized MacroInfos were not destroyed and if their SmallVector did heap allocation,
it was leaked.
rdar://13768967
llvm-svn: 180771
Diffstat (limited to 'clang/lib/Lex/PPDirectives.cpp')
-rw-r--r-- | clang/lib/Lex/PPDirectives.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index 3cd40eacf8a..50a0cb55f73 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -61,9 +61,12 @@ MacroInfo *Preprocessor::AllocateDeserializedMacroInfo(SourceLocation L, unsigned SubModuleID) { LLVM_STATIC_ASSERT(llvm::AlignOf<MacroInfo>::Alignment >= sizeof(SubModuleID), "alignment for MacroInfo is less than the ID"); - MacroInfo *MI = - (MacroInfo*)BP.Allocate(sizeof(MacroInfo) + sizeof(SubModuleID), - llvm::AlignOf<MacroInfo>::Alignment); + DeserializedMacroInfoChain *MIChain = + BP.Allocate<DeserializedMacroInfoChain>(); + MIChain->Next = DeserialMIChainHead; + DeserialMIChainHead = MIChain; + + MacroInfo *MI = &MIChain->MI; new (MI) MacroInfo(L); MI->FromASTFile = true; MI->setOwningModuleID(SubModuleID); |