Skip to content

Commit 1fd2ac5

Browse files
authored
Merge pull request #31879 from CodaFi/mtimes-often-lie
[NFC] Clean Up Some Unneeded TypeCheckerOptions
2 parents 976890d + 854d6ee commit 1fd2ac5

File tree

4 files changed

+11
-57
lines changed

4 files changed

+11
-57
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,7 @@ namespace swift {
484484
/// 4.2 GHz Intel Core i7.
485485
/// (It's arbitrary, but will keep the compiler from taking too much time.)
486486
unsigned SwitchCheckingInvocationThreshold = 200000;
487-
488-
/// Whether to delay checking that benefits from having the entire
489-
/// module parsed, e.g., Objective-C method override checking.
490-
bool DelayWholeModuleChecking = false;
491-
487+
492488
/// If true, the time it takes to type-check each function will be dumped
493489
/// to llvm::errs().
494490
bool DebugTimeFunctionBodies = false;
@@ -497,11 +493,6 @@ namespace swift {
497493
/// dumped to llvm::errs().
498494
bool DebugTimeExpressions = false;
499495

500-
/// Indicate that the type checker is checking code that will be
501-
/// immediately executed. This will suppress certain warnings
502-
/// when executing scripts.
503-
bool InImmediateMode = false;
504-
505496
/// Indicate that the type checker should skip type-checking non-inlinable
506497
/// function bodies.
507498
bool SkipNonInlinableFunctionBodies = false;

lib/AST/TypeCheckRequests.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,24 +1451,6 @@ void TypeCheckSourceFileRequest::cacheResult(evaluator::SideEffect) const {
14511451
FrontendStatsTracer tracer(Ctx.Stats, "AST verification");
14521452
// Verify the SourceFile.
14531453
swift::verify(*SF);
1454-
1455-
// Verify imported modules.
1456-
//
1457-
// Skip per-file verification in whole-module mode. Verifying imports
1458-
// between files could cause the importer to cache declarations without
1459-
// adding them to the ASTContext. This happens when the importer registers a
1460-
// declaration without a valid TypeChecker instance, as is the case during
1461-
// verification. A subsequent file may require that declaration to be fully
1462-
// imported (e.g. to synthesized a function body), but since it has already
1463-
// been cached, it will never be added to the ASTContext. The solution is to
1464-
// skip verification and avoid caching it.
1465-
#ifndef NDEBUG
1466-
if (!Ctx.TypeCheckerOpts.DelayWholeModuleChecking &&
1467-
SF->Kind != SourceFileKind::SIL &&
1468-
!Ctx.LangOpts.DebuggerSupport) {
1469-
Ctx.verifyAllLoadedModules();
1470-
}
1471-
#endif
14721454
}
14731455
}
14741456

lib/Frontend/Frontend.cpp

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -311,15 +311,6 @@ bool CompilerInstance::setup(const CompilerInvocation &Invok) {
311311
Invocation.getLangOptions().AttachCommentsToDecls = true;
312312
}
313313

314-
// Set up the type checker options.
315-
auto &typeCkOpts = Invocation.getTypeCheckerOptions();
316-
if (isWholeModuleCompilation()) {
317-
typeCkOpts.DelayWholeModuleChecking = true;
318-
}
319-
if (FrontendOptions::isActionImmediate(frontendOpts.RequestedAction)) {
320-
typeCkOpts.InImmediateMode = true;
321-
}
322-
323314
assert(Lexer::isIdentifier(Invocation.getModuleName()));
324315

325316
if (isInSILMode())
@@ -871,19 +862,16 @@ bool CompilerInstance::loadPartialModulesAndImplicitImports() {
871862
return hadLoadError;
872863
}
873864

874-
static void
875-
forEachSourceFileIn(ModuleDecl *module,
876-
llvm::function_ref<void(SourceFile &)> fn) {
877-
for (auto fileName : module->getFiles()) {
878-
if (auto SF = dyn_cast<SourceFile>(fileName))
879-
fn(*SF);
880-
}
881-
}
882-
883865
void CompilerInstance::forEachFileToTypeCheck(
884866
llvm::function_ref<void(SourceFile &)> fn) {
885867
if (isWholeModuleCompilation()) {
886-
forEachSourceFileIn(MainModule, [&](SourceFile &SF) { fn(SF); });
868+
for (auto fileName : MainModule->getFiles()) {
869+
auto *SF = dyn_cast<SourceFile>(fileName);
870+
if (!SF) {
871+
continue;
872+
}
873+
fn(*SF);
874+
}
887875
} else {
888876
for (auto *SF : PrimarySourceFiles) {
889877
fn(*SF);
@@ -892,11 +880,9 @@ void CompilerInstance::forEachFileToTypeCheck(
892880
}
893881

894882
void CompilerInstance::finishTypeChecking() {
895-
if (getASTContext().TypeCheckerOpts.DelayWholeModuleChecking) {
896-
forEachSourceFileIn(MainModule, [&](SourceFile &SF) {
897-
performWholeModuleTypeChecking(SF);
898-
});
899-
}
883+
forEachFileToTypeCheck([](SourceFile &SF) {
884+
performWholeModuleTypeChecking(SF);
885+
});
900886
}
901887

902888
SourceFile *CompilerInstance::createSourceFileForMainModule(

lib/Sema/TypeChecker.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,6 @@ TypeCheckSourceFileRequest::evaluate(Evaluator &eval, SourceFile *SF) const {
357357
CheckInconsistentImplementationOnlyImportsRequest{SF->getParentModule()},
358358
{});
359359

360-
// Checking that benefits from having the whole module available.
361-
if (!Ctx.TypeCheckerOpts.DelayWholeModuleChecking) {
362-
performWholeModuleTypeChecking(*SF);
363-
}
364-
365360
// Perform various AST transforms we've been asked to perform.
366361
if (!Ctx.hadError() && Ctx.LangOpts.DebuggerTestingTransform)
367362
performDebuggerTestingTransform(*SF);

0 commit comments

Comments
 (0)