Move parts of Parse to another function
This commit is contained in:
parent
419c25e5f2
commit
f4471da415
@ -915,8 +915,52 @@ namespace cling {
|
||||
PP.EnterSourceFile(FID, /*DirLookup*/nullptr, NewLoc);
|
||||
m_Consumer->getTransaction()->setBufferFID(FID);
|
||||
|
||||
if (!ParseOrWrapTopLevelDecl())
|
||||
return kFailed;
|
||||
|
||||
#ifdef _WIN32
|
||||
// Microsoft-specific:
|
||||
// Late parsed templates can leave unswallowed "macro"-like tokens.
|
||||
// They will seriously confuse the Parser when entering the next
|
||||
// source file. So lex until we are EOF.
|
||||
Token Tok;
|
||||
Tok.setKind(tok::eof);
|
||||
do {
|
||||
PP.Lex(Tok);
|
||||
} while (Tok.isNot(tok::eof));
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG
|
||||
Token AssertTok;
|
||||
PP.Lex(AssertTok);
|
||||
assert(AssertTok.is(tok::eof) &&
|
||||
"Lexer must be EOF when starting incremental parse!");
|
||||
#endif
|
||||
|
||||
// Process any TopLevelDecls generated by #pragma weak.
|
||||
for (llvm::SmallVector<Decl*, 2>::iterator
|
||||
I = S.WeakTopLevelDecls().begin(),
|
||||
E = S.WeakTopLevelDecls().end();
|
||||
I != E; ++I) {
|
||||
m_Consumer->HandleTopLevelDecl(DeclGroupRef(*I));
|
||||
}
|
||||
|
||||
DiagnosticsEngine& Diags = getCI()->getDiagnostics();
|
||||
if (m_Consumer->getTransaction()->getIssuedDiags() == Transaction::kErrors)
|
||||
return kFailed;
|
||||
else if (Diags.getNumWarnings())
|
||||
return kSuccessWithWarnings;
|
||||
|
||||
return kSuccess;
|
||||
}
|
||||
|
||||
llvm::Expected<bool> IncrementalParser::ParseOrWrapTopLevelDecl() {
|
||||
// Recover resources if we crash before exiting this method.
|
||||
Sema& S = getCI()->getSema();
|
||||
DiagnosticsEngine& Diags = getCI()->getDiagnostics();
|
||||
|
||||
const CompilationOptions& CO =
|
||||
m_Consumer->getTransaction()->getCompilationOpts();
|
||||
FilteringDiagConsumer::RAAI RAAITmp(*m_DiagConsumer, CO.IgnorePromptDiags);
|
||||
|
||||
DiagnosticErrorTrap Trap(Diags);
|
||||
@ -952,40 +996,12 @@ namespace cling {
|
||||
// Let's ignore this transaction:
|
||||
m_Consumer->getTransaction()->setIssuedDiags(Transaction::kErrors);
|
||||
|
||||
return kSuccess;
|
||||
return true;
|
||||
}
|
||||
LocalInstantiations.perform();
|
||||
GlobalInstantiations.perform();
|
||||
#ifdef _WIN32
|
||||
// Microsoft-specific:
|
||||
// Late parsed templates can leave unswallowed "macro"-like tokens.
|
||||
// They will seriously confuse the Parser when entering the next
|
||||
// source file. So lex until we are EOF.
|
||||
Token Tok;
|
||||
Tok.setKind(tok::eof);
|
||||
do {
|
||||
PP.Lex(Tok);
|
||||
} while (Tok.isNot(tok::eof));
|
||||
#endif
|
||||
|
||||
#ifndef NDEBUG
|
||||
Token AssertTok;
|
||||
PP.Lex(AssertTok);
|
||||
assert(AssertTok.is(tok::eof) && "Lexer must be EOF when starting incremental parse!");
|
||||
#endif
|
||||
|
||||
// Process any TopLevelDecls generated by #pragma weak.
|
||||
for (llvm::SmallVector<Decl*,2>::iterator I = S.WeakTopLevelDecls().begin(),
|
||||
E = S.WeakTopLevelDecls().end(); I != E; ++I) {
|
||||
m_Consumer->HandleTopLevelDecl(DeclGroupRef(*I));
|
||||
}
|
||||
|
||||
if (m_Consumer->getTransaction()->getIssuedDiags() == Transaction::kErrors)
|
||||
return kFailed;
|
||||
else if (Diags.getNumWarnings())
|
||||
return kSuccessWithWarnings;
|
||||
|
||||
return kSuccess;
|
||||
return true;
|
||||
}
|
||||
|
||||
void IncrementalParser::printTransactionStructure() const {
|
||||
|
@ -253,6 +253,8 @@ namespace cling {
|
||||
///
|
||||
EParseResult ParseInternal(llvm::StringRef input);
|
||||
|
||||
llvm::Expected<bool> ParseOrWrapTopLevelDecl();
|
||||
|
||||
///\brief Create a unique name for the next llvm::Module
|
||||
///
|
||||
std::string makeModuleName();
|
||||
|
Loading…
x
Reference in New Issue
Block a user