Skip to content

Commit

Permalink
[cling] Use single Parser for LookupHelper
Browse files Browse the repository at this point in the history
It is the only construction of a temporary parser, and it seems not
necessary (anymore).
  • Loading branch information
hahnjo committed Jan 6, 2025
1 parent ce23391 commit 71333a4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion interpreter/cling/include/cling/Interpreter/LookupHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace cling {
WithDiagnostics
};
private:
std::unique_ptr<clang::Parser> m_Parser;
clang::Parser* m_Parser;
Interpreter* m_Interpreter; // we do not own.
std::array<const clang::Type*, kNumCachedStrings> m_StringTy = {{}};
/// A map containing the hash of the lookup buffer. This allows us to avoid
Expand Down
11 changes: 4 additions & 7 deletions interpreter/cling/lib/Interpreter/Interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,6 @@ namespace cling {
}

Sema& SemaRef = getSema();
Preprocessor& PP = SemaRef.getPreprocessor();

m_LookupHelper.reset(new LookupHelper(new Parser(PP, SemaRef,
/*SkipFunctionBodies*/false,
/*isTemp*/true), this));
if (!m_LookupHelper)
return;

if (!isInSyntaxOnlyMode() && !m_Opts.CompilerOpts.CUDADevice) {
m_Executor.reset(new IncrementalExecutor(SemaRef.Diags, *getCI(),
Expand Down Expand Up @@ -317,6 +310,10 @@ namespace cling {
return;
}

m_LookupHelper.reset(new LookupHelper(m_IncrParser->getParser(), this));
if (!m_LookupHelper)
return;

// When not using C++ modules, we now have a PCH and we can safely setup
// our callbacks without fearing that they get overwritten by clang code.
// The modules setup is handled above.
Expand Down

0 comments on commit 71333a4

Please sign in to comment.