Skip to content

Commit 55cf78b

Browse files
committed
[Frontend] Inline performSemaUpTo
Now that it no longer needs to handle the parse-only case, we can simplify things by having `performSema` call into `performParseAndResolveImportsOnly`.
1 parent 1ed8106 commit 55cf78b

File tree

2 files changed

+9
-29
lines changed

2 files changed

+9
-29
lines changed

include/swift/Frontend/Frontend.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,6 @@ class CompilerInstance {
652652
/// Retrieve a description of which modules should be implicitly imported.
653653
ImplicitImportInfo getImplicitImportInfo() const;
654654

655-
void performSemaUpTo(SourceFile::ASTStage_t LimitStage);
656-
657655
/// For any serialized AST inputs, loads them in as partial module files,
658656
/// appending them to \p partialModules. If a loading error occurs, returns
659657
/// \c true.

lib/Frontend/Frontend.cpp

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -777,35 +777,15 @@ void CompilerInstance::setMainModule(ModuleDecl *newMod) {
777777
}
778778

779779
void CompilerInstance::performParseAndResolveImportsOnly() {
780-
performSemaUpTo(SourceFile::ImportsResolved);
781-
}
782-
783-
void CompilerInstance::performSema() {
784-
performSemaUpTo(SourceFile::TypeChecked);
785-
}
786-
787-
void CompilerInstance::performSemaUpTo(SourceFile::ASTStage_t LimitStage) {
788-
FrontendStatsTracer tracer(getStatsReporter(), "perform-sema");
789-
790-
ModuleDecl *mainModule = getMainModule();
780+
FrontendStatsTracer tracer(getStatsReporter(), "parse-and-resolve-imports");
791781

792-
// Then parse all the input files.
782+
// Resolve imports for all the source files.
783+
auto *mainModule = getMainModule();
793784
for (auto *file : mainModule->getFiles()) {
794-
auto *SF = dyn_cast<SourceFile>(file);
795-
if (!SF)
796-
continue;
797-
798-
// Trigger parsing of the file.
799-
if (LimitStage == SourceFile::Unprocessed) {
800-
(void)SF->getTopLevelDecls();
801-
} else {
785+
if (auto *SF = dyn_cast<SourceFile>(file))
802786
performImportResolution(*SF);
803-
}
804787
}
805788

806-
if (LimitStage == SourceFile::Unprocessed)
807-
return;
808-
809789
assert(llvm::all_of(mainModule->getFiles(), [](const FileUnit *File) -> bool {
810790
auto *SF = dyn_cast<SourceFile>(File);
811791
if (!SF)
@@ -815,10 +795,12 @@ void CompilerInstance::performSemaUpTo(SourceFile::ASTStage_t LimitStage) {
815795
mainModule->setHasResolvedImports();
816796

817797
bindExtensions(*mainModule);
798+
}
818799

819-
// If the limiting AST stage is import resolution, we're done.
820-
if (LimitStage == SourceFile::ImportsResolved)
821-
return;
800+
void CompilerInstance::performSema() {
801+
performParseAndResolveImportsOnly();
802+
803+
FrontendStatsTracer tracer(getStatsReporter(), "perform-sema");
822804

823805
forEachFileToTypeCheck([&](SourceFile &SF) {
824806
performTypeChecking(SF);

0 commit comments

Comments
 (0)