[Frontend] Inline parseAndCheckTypesUpTo

`performSemaUpTo` will only shrink from here, so
go ahead and inline `parseAndCheckTypesUpTo` into
it already.
This commit is contained in:
Hamish Knight
2020-04-24 14:32:35 -07:00
parent b78f47490a
commit 9fe475fa47
2 changed files with 34 additions and 42 deletions

View File

@@ -794,7 +794,40 @@ void CompilerInstance::performSemaUpTo(SourceFile::ASTStage_t LimitStage) {
MainBufferID);
}
parseAndCheckTypesUpTo(LimitStage);
bool hadLoadError = parsePartialModulesAndInputFiles();
if (hadLoadError)
return;
assert(llvm::all_of(MainModule->getFiles(), [](const FileUnit *File) -> bool {
auto *SF = dyn_cast<SourceFile>(File);
if (!SF)
return true;
return SF->ASTStage >= SourceFile::ImportsResolved;
}) && "some files have not yet had their imports resolved");
MainModule->setHasResolvedImports();
forEachFileToTypeCheck([&](SourceFile &SF) {
if (LimitStage == SourceFile::ImportsResolved) {
bindExtensions(SF);
return;
}
performTypeChecking(SF);
// Parse the SIL decls if needed.
// TODO: Requestify SIL parsing.
if (TheSILModule) {
SILParserState SILContext(TheSILModule.get());
parseSourceFileSIL(SF, &SILContext);
}
});
// If the limiting AST stage is import resolution, we're done.
if (LimitStage <= SourceFile::ImportsResolved) {
return;
}
finishTypeChecking();
}
bool CompilerInstance::loadStdlib() {
@@ -816,46 +849,6 @@ bool CompilerInstance::loadStdlib() {
return true;
}
void CompilerInstance::parseAndCheckTypesUpTo(
SourceFile::ASTStage_t limitStage) {
FrontendStatsTracer tracer(getStatsReporter(), "parse-and-check-types");
bool hadLoadError = parsePartialModulesAndInputFiles();
if (hadLoadError)
return;
assert(llvm::all_of(MainModule->getFiles(), [](const FileUnit *File) -> bool {
auto *SF = dyn_cast<SourceFile>(File);
if (!SF)
return true;
return SF->ASTStage >= SourceFile::ImportsResolved;
}) && "some files have not yet had their imports resolved");
MainModule->setHasResolvedImports();
forEachFileToTypeCheck([&](SourceFile &SF) {
if (limitStage == SourceFile::ImportsResolved) {
bindExtensions(SF);
return;
}
performTypeChecking(SF);
// Parse the SIL decls if needed.
// TODO: Requestify SIL parsing.
if (TheSILModule) {
SILParserState SILContext(TheSILModule.get());
parseSourceFileSIL(SF, &SILContext);
}
});
// If the limiting AST stage is import resolution, we're done.
if (limitStage <= SourceFile::ImportsResolved) {
return;
}
finishTypeChecking();
}
bool CompilerInstance::parsePartialModulesAndInputFiles() {
FrontendStatsTracer tracer(getStatsReporter(),
"parse-partial-modules-and-input-files");