Skip to content

Commit

Permalink
Forcefully clean up TemplateIdAnnotations
Browse files Browse the repository at this point in the history
Upstream Clang keeps TemplateIdAnnotations around "if they might
still be in the token stream." See upstream commit for more details:
llvm/llvm-project@6163aa9
(included in Clang 11, in ROOT since the upgrade to LLVM 13)

This reasoning doesn't apply when we fully reset the Parser state in
ParserStateRAII's destructor, and we expect the swapped out vector of
TemplateIdAnnotations to be empty in order to not leak.

Fixes #16121
  • Loading branch information
hahnjo authored and jenkins committed Aug 2, 2024
1 parent 42d2fb1 commit afd3692
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/Utils/ParserStateRAII.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ cling::ParserStateRAII::~ParserStateRAII() {
// Note: Consuming the EOF token will pop the include stack.
//
{
// Cleanup the TemplateIds before swapping the previous set back.
Parser::DestroyTemplateIdAnnotationsRAIIObj CleanupTemplateIds(*P);
// Forcefully clean up the TemplateIds, ignoring additional checks in
// MaybeDestroyTemplateIds called from DestroyTemplateIdAnnotationsRAIIObj,
// before swapping the previous set back.
P->DestroyTemplateIds();
}
P->TemplateIds.swap(OldTemplateIds);
assert(OldTemplateIds.empty());
if (SkipToEOF)
P->SkipUntil(tok::eof);
else
Expand Down

0 comments on commit afd3692

Please sign in to comment.