Capture/reset expression eval context (ROOT-10511):

Without resetting the eval context to the Parser default (PotentiallyEvaluated),
recursive parsing can potentially assume wrong context and not emit referenced entities.
This commit is contained in:
Axel Naumann 2020-02-14 10:30:25 +01:00 committed by SFT
parent 7a5894d1b8
commit 9220b498f3
2 changed files with 3 additions and 1 deletions

View File

@ -42,6 +42,7 @@ namespace cling {
unsigned OldTemplateParameterDepth;
bool OldInNonInstantiationSFINAEContext;
bool SkipToEOF;
clang::EnterExpressionEvaluationContext ResetExprEvalCtx;
public:
ParserStateRAII(clang::Parser& p, bool skipToEOF);

View File

@ -30,7 +30,8 @@ cling::ParserStateRAII::ParserStateRAII(Parser& p, bool skipToEOF)
OldTemplateParameterDepth(p.TemplateParameterDepth),
OldInNonInstantiationSFINAEContext(P->getActions()
.InNonInstantiationSFINAEContext),
SkipToEOF(skipToEOF)
SkipToEOF(skipToEOF),
ResetExprEvalCtx(p.getActions(), clang::Sema::ExpressionEvaluationContext::PotentiallyEvaluated)
{
// Set to defaults, reset to previous values by ~ParserStateRAII().
OldTemplateIds.swap(P->TemplateIds);