Forcefully clean up TemplateIdAnnotations

Upstream Clang keeps TemplateIdAnnotations around "if they might
still be in the token stream." See upstream commit for more details:
6163aa9679
(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
This commit is contained in:
Jonas Hahnfeld 2024-08-01 10:39:22 +02:00 committed by jenkins
parent 42d2fb1493
commit afd3692787

View File

@ -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