summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/PPDirectives.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2010-10-19 18:16:54 +0000
committerTed Kremenek <kremenek@apple.com>2010-10-19 18:16:54 +0000
commit1f1e4bdbf7815c7c3ce90d3035b9615515e0c1aa (patch)
treeaa7bcd4bca38ac62d081ac4ac27ef10d3a77482c /clang/lib/Lex/PPDirectives.cpp
parent6162f9774a0dd84f1c72f43d4ad11880f36cae7d (diff)
downloadbcm5719-llvm-1f1e4bdbf7815c7c3ce90d3035b9615515e0c1aa.tar.gz
bcm5719-llvm-1f1e4bdbf7815c7c3ce90d3035b9615515e0c1aa.zip
Simplify lifetime management of MacroInfo objects in Preprocessor by having the Preprocessor maintain them in a linked
list of allocated MacroInfos. This requires only 1 extra pointer per MacroInfo object, and allows us to blow them away in one place. This fixes an elusive memory leak with MacroInfos (whose exact location I couldn't still figure out despite substantial digging). Fixes <rdar://problem/8361834>. llvm-svn: 116842
Diffstat (limited to 'clang/lib/Lex/PPDirectives.cpp')
-rw-r--r--clang/lib/Lex/PPDirectives.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 5e3b16e60de..ffdc6ae5894 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -33,8 +33,12 @@ MacroInfo *Preprocessor::AllocateMacroInfo() {
if (!MICache.empty()) {
MI = MICache.back();
MICache.pop_back();
- } else
- MI = (MacroInfo*) BP.Allocate<MacroInfo>();
+ } else {
+ MacroInfoChain *MIChain = BP.Allocate<MacroInfoChain>();
+ MIChain->Next = MIChainHead;
+ MIChainHead = MIChain;
+ MI = &(MIChainHead->MI);
+ }
return MI;
}
OpenPOWER on IntegriCloud