@@ -55,10 +55,8 @@ std::string CompilerInvocation::getPCHHash() const {
55
55
56
56
void CompilerInstance::createSILModule () {
57
57
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 ();
60
58
TheSILModule = SILModule::createEmptyModule (
61
- getMainModule (), Invocation.getSILOptions (), WholeModule );
59
+ getMainModule (), Invocation.getSILOptions (), isWholeModuleCompilation () );
62
60
}
63
61
64
62
void CompilerInstance::setPrimarySourceFile (SourceFile *SF) {
@@ -436,7 +434,6 @@ void CompilerInstance::getImplicitlyImportedModules(
436
434
437
435
void CompilerInstance::createREPLFile (
438
436
const ImplicitImports &implicitImports) const {
439
- SharedTimer timer (" performSema-createREPLFile" );
440
437
auto *SingleInputFile = new (*Context) SourceFile (
441
438
*MainModule, Invocation.getSourceFileKind (), None, implicitImports.kind ,
442
439
Invocation.getLangOptions ().KeepTokensInSourceFile );
@@ -456,8 +453,6 @@ CompilerInstance::computeDelayedParsingCallback() {
456
453
457
454
void CompilerInstance::addMainFileToModule (
458
455
const ImplicitImports &implicitImports) {
459
- SharedTimer timer (" performSema-addMainFileToModule" );
460
-
461
456
const InputFileKind Kind = Invocation.getInputKind ();
462
457
assert (Kind == InputFileKind::IFK_Swift || Kind == InputFileKind::IFK_SIL);
463
458
@@ -496,8 +491,10 @@ void CompilerInstance::parseAndCheckTypes(
496
491
497
492
OptionSet<TypeCheckingFlags> TypeCheckOptions = computeTypeCheckingOptions ();
498
493
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.
501
498
if (MainBufferID != NO_SUCH_BUFFER) {
502
499
parseAndTypeCheckMainFile (PersistentState, DelayedCB.get (),
503
500
TypeCheckOptions);
@@ -657,7 +654,7 @@ void CompilerInstance::parseAndTypeCheckMainFile(
657
654
658
655
static void
659
656
forEachSourceFileIn (ModuleDecl *module ,
660
- const llvm::function_ref<void (SourceFile &)> & fn) {
657
+ llvm::function_ref<void (SourceFile &)> fn) {
661
658
for (auto File : module ->getFiles ()) {
662
659
if (auto SF = dyn_cast<SourceFile>(File))
663
660
fn (*SF);
@@ -680,7 +677,7 @@ void CompilerInstance::finishTypeChecking(
680
677
performWholeModuleTypeChecking (SF);
681
678
});
682
679
}
683
- forEachFileToTypeCheck ([&](SourceFile &SF) { finishTypeCheckingOfFile (SF); });
680
+ forEachFileToTypeCheck ([&](SourceFile &SF) { finishTypeCheckingFile (SF); });
684
681
}
685
682
686
683
void CompilerInstance::performParseOnly (bool EvaluateConditionals) {
0 commit comments