Support recursive lookup helper calls.
The implementation of class->library mapping makes a call to the LookupHelper::findScope. This makes the recursive invocations to LookupHelper::findScope -> ... -> LookupHelper::findScope happen more often.
This commit is contained in:
parent
d5163b6290
commit
d71643dcf8
@ -71,6 +71,8 @@ namespace cling {
|
||||
unsigned m_CacheHits = 0;
|
||||
/// Number of times we missed the cache.
|
||||
unsigned m_TotalParseRequests = 0;
|
||||
/// If we are called recursively.
|
||||
bool IsRecursivelyRunning = false;
|
||||
|
||||
public:
|
||||
LookupHelper(clang::Parser* P, Interpreter* interp);
|
||||
|
@ -36,6 +36,7 @@ namespace cling {
|
||||
bool OldSuppressAllDiagnostics;
|
||||
bool OldPPSuppressAllDiagnostics;
|
||||
bool OldSpellChecking;
|
||||
clang::Token OldTok;
|
||||
clang::SourceLocation OldPrevTokLocation;
|
||||
unsigned short OldParenCount, OldBracketCount, OldBraceCount;
|
||||
unsigned OldTemplateParameterDepth;
|
||||
|
@ -37,17 +37,20 @@ namespace cling {
|
||||
|
||||
class StartParsingRAII {
|
||||
LookupHelper& m_LH;
|
||||
llvm::SaveAndRestore<bool> SaveIsRecursivelyRunning;
|
||||
ParserStateRAII ResetParserState;
|
||||
|
||||
void prepareForParsing(llvm::StringRef code, llvm::StringRef bufferName,
|
||||
LookupHelper::DiagSetting diagOnOff);
|
||||
public:
|
||||
StartParsingRAII(LookupHelper& LH, llvm::StringRef code,
|
||||
llvm::StringRef bufferName,
|
||||
LookupHelper::DiagSetting diagOnOff)
|
||||
: m_LH(LH), ResetParserState(*LH.m_Parser.get(), true /*skipToEOF*/) {
|
||||
prepareForParsing(code, bufferName, diagOnOff);
|
||||
}
|
||||
: m_LH(LH), SaveIsRecursivelyRunning(LH.IsRecursivelyRunning),
|
||||
ResetParserState(*LH.m_Parser.get(),
|
||||
!LH.IsRecursivelyRunning /*skipToEOF*/) {
|
||||
LH.IsRecursivelyRunning = true;
|
||||
prepareForParsing(code, bufferName, diagOnOff);
|
||||
}
|
||||
|
||||
~StartParsingRAII() { pop(); }
|
||||
void pop() const {}
|
||||
@ -84,7 +87,8 @@ namespace cling {
|
||||
if (!PP.isIncrementalProcessingEnabled()) {
|
||||
PP.enableIncrementalProcessing();
|
||||
}
|
||||
assert(!code.empty()&&"prepareForParsing should only be called when needd");
|
||||
assert(!code.empty() &&
|
||||
"prepareForParsing should only be called when need");
|
||||
|
||||
// Create a fake file to parse the type name.
|
||||
FileID FID;
|
||||
|
@ -24,7 +24,7 @@ cling::ParserStateRAII::ParserStateRAII(Parser& p, bool skipToEOF)
|
||||
OldPPSuppressAllDiagnostics(p.getPreprocessor().getDiagnostics()
|
||||
.getSuppressAllDiagnostics()),
|
||||
OldSpellChecking(p.getPreprocessor().getLangOpts().SpellChecking),
|
||||
OldPrevTokLocation(p.PrevTokLocation),
|
||||
OldTok(p.Tok), OldPrevTokLocation(p.PrevTokLocation),
|
||||
OldParenCount(p.ParenCount), OldBracketCount(p.BracketCount),
|
||||
OldBraceCount(p.BraceCount),
|
||||
OldTemplateParameterDepth(p.TemplateParameterDepth),
|
||||
@ -54,6 +54,8 @@ cling::ParserStateRAII::~ParserStateRAII() {
|
||||
P->TemplateIds.swap(OldTemplateIds);
|
||||
if (SkipToEOF)
|
||||
P->SkipUntil(tok::eof);
|
||||
else
|
||||
P->Tok = OldTok;
|
||||
PP.enableIncrementalProcessing(ResetIncrementalProcessing);
|
||||
if (!SemaDiagHadErrors) {
|
||||
// Doesn't reset the diagnostic mappings
|
||||
|
Loading…
x
Reference in New Issue
Block a user