Skip to content

Commit 097dd71

Browse files
author
David Ungar
committed
Simple fixes per Jordan's comments:
- Use isWholeModuleCompilation in CompilerInstance::createSILModule - Remove some unneeded timers - Improve the comment in CompilerInstance::parseAndCheckTypes - Remove needless const ref to an llvm::function_ref parameter in forEachSourceFileIn - Remove "OfFile" from "finishTypeCheckingOfFile"
1 parent edac126 commit 097dd71

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

include/swift/Subsystems.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ namespace swift {
186186

187187
/// Once type checking is complete, this walks protocol requirements
188188
/// to resolve default witnesses.
189-
void finishTypeCheckingOfFile(SourceFile &SF);
189+
void finishTypeCheckingFile(SourceFile &SF);
190190

191191
/// Now that we have type-checked an entire module, perform any type
192192
/// checking that requires the full module, e.g., Objective-C method

lib/Frontend/Frontend.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,8 @@ std::string CompilerInvocation::getPCHHash() const {
5555

5656
void CompilerInstance::createSILModule() {
5757
assert(MainModule && "main module not created yet");
58-
// Assume WMO if a -primary-file option was not provided.
59-
bool WholeModule = !Invocation.getFrontendOptions().PrimaryInput.hasValue();
6058
TheSILModule = SILModule::createEmptyModule(
61-
getMainModule(), Invocation.getSILOptions(), WholeModule);
59+
getMainModule(), Invocation.getSILOptions(), isWholeModuleCompilation());
6260
}
6361

6462
void CompilerInstance::setPrimarySourceFile(SourceFile *SF) {
@@ -436,7 +434,6 @@ void CompilerInstance::getImplicitlyImportedModules(
436434

437435
void CompilerInstance::createREPLFile(
438436
const ImplicitImports &implicitImports) const {
439-
SharedTimer timer("performSema-createREPLFile");
440437
auto *SingleInputFile = new (*Context) SourceFile(
441438
*MainModule, Invocation.getSourceFileKind(), None, implicitImports.kind,
442439
Invocation.getLangOptions().KeepTokensInSourceFile);
@@ -456,8 +453,6 @@ CompilerInstance::computeDelayedParsingCallback() {
456453

457454
void CompilerInstance::addMainFileToModule(
458455
const ImplicitImports &implicitImports) {
459-
SharedTimer timer("performSema-addMainFileToModule");
460-
461456
const InputFileKind Kind = Invocation.getInputKind();
462457
assert(Kind == InputFileKind::IFK_Swift || Kind == InputFileKind::IFK_SIL);
463458

@@ -496,8 +491,10 @@ void CompilerInstance::parseAndCheckTypes(
496491

497492
OptionSet<TypeCheckingFlags> TypeCheckOptions = computeTypeCheckingOptions();
498493

499-
// Parse main file last in order to make sure that it can use decls from other
500-
// files in the module.
494+
// Type-check main file after parsing all other files so that
495+
// it can use declarations from other files.
496+
// In addition, the main file has parsing and type-checking
497+
// interwined.
501498
if (MainBufferID != NO_SUCH_BUFFER) {
502499
parseAndTypeCheckMainFile(PersistentState, DelayedCB.get(),
503500
TypeCheckOptions);
@@ -657,7 +654,7 @@ void CompilerInstance::parseAndTypeCheckMainFile(
657654

658655
static void
659656
forEachSourceFileIn(ModuleDecl *module,
660-
const llvm::function_ref<void(SourceFile &)> &fn) {
657+
llvm::function_ref<void(SourceFile &)> fn) {
661658
for (auto File : module->getFiles()) {
662659
if (auto SF = dyn_cast<SourceFile>(File))
663660
fn(*SF);
@@ -680,7 +677,7 @@ void CompilerInstance::finishTypeChecking(
680677
performWholeModuleTypeChecking(SF);
681678
});
682679
}
683-
forEachFileToTypeCheck([&](SourceFile &SF) { finishTypeCheckingOfFile(SF); });
680+
forEachFileToTypeCheck([&](SourceFile &SF) { finishTypeCheckingFile(SF); });
684681
}
685682

686683
void CompilerInstance::performParseOnly(bool EvaluateConditionals) {

lib/Sema/TypeChecker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ void swift::performTypeChecking(SourceFile &SF, TopLevelContext &TLC,
668668
}
669669
}
670670

671-
void swift::finishTypeCheckingOfFile(SourceFile &SF) {
671+
void swift::finishTypeCheckingFile(SourceFile &SF) {
672672
auto &Ctx = SF.getASTContext();
673673
TypeChecker TC(Ctx);
674674

0 commit comments

Comments
 (0)