summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/PPDirectives.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-04-30 05:05:35 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-04-30 05:05:35 +0000
commitd48b91dbbe63e60e214c62d8cda4d20bc3347015 (patch)
tree6d987c8afd3aa8d84f3cd350250f1771e23e8186 /clang/lib/Lex/PPDirectives.cpp
parent95012aaa9371fe1b6dd95749753d75eb6ed1ac20 (diff)
downloadbcm5719-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.cpp9
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);
OpenPOWER on IntegriCloud