diff options
author | Reid Kleckner <reid@kleckner.net> | 2014-10-22 17:50:19 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2014-10-22 17:50:19 +0000 |
commit | 89bd8d62f3c3305d4ec433307dc4c0b1df1d4be7 (patch) | |
tree | 80abf7c31dda4fb53511773fb0dc72324b862f6c /clang/lib/Parse/Parser.cpp | |
parent | db0856658810b47f29986a9a1dea5b6ae9ceab35 (diff) | |
download | bcm5719-llvm-89bd8d62f3c3305d4ec433307dc4c0b1df1d4be7.tar.gz bcm5719-llvm-89bd8d62f3c3305d4ec433307dc4c0b1df1d4be7.zip |
Reland r219810 "Fix late template parsing leak with incremental processing"
Original message:
Add a second late template parser callback meant to cleanup any
resources allocated by late template parsing. Call it from the
Sema::ActOnEndOfTranslationUnit method after all pending template
instantiations have been completed. Teach Parser::ParseTopLevelDecl to
install the cleanup callback when incremental processing is enabled so
that Parser::TemplateIds can be freed.
Patch by Brad King!
llvm-svn: 220400
Diffstat (limited to 'clang/lib/Parse/Parser.cpp')
-rw-r--r-- | clang/lib/Parse/Parser.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index 27a852e9ff2..93e893e723b 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -510,6 +510,13 @@ namespace { }; } +void Parser::LateTemplateParserCleanupCallback(void *P) { + // While this RAII helper doesn't bracket any actual work, the destructor will + // clean up annotations that were created during ActOnEndOfTranslationUnit + // when incremental processing is enabled. + DestroyTemplateIdAnnotationsRAIIObj CleanupRAII(((Parser *)P)->TemplateIds); +} + /// ParseTopLevelDecl - Parse one top-level declaration, return whatever the /// action tells us to. This returns true if the EOF was encountered. bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result) { @@ -542,7 +549,10 @@ bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result) { case tok::eof: // Late template parsing can begin. if (getLangOpts().DelayedTemplateParsing) - Actions.SetLateTemplateParser(LateTemplateParserCallback, this); + Actions.SetLateTemplateParser(LateTemplateParserCallback, + PP.isIncrementalProcessingEnabled() ? + LateTemplateParserCleanupCallback : nullptr, + this); if (!PP.isIncrementalProcessingEnabled()) Actions.ActOnEndOfTranslationUnit(); //else don't tell Sema that we ended parsing: more input might come. |