Skip to content

[NFC] Clean Up Some Unneeded TypeCheckerOptions #31879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions include/swift/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,7 @@ namespace swift {
/// 4.2 GHz Intel Core i7.
/// (It's arbitrary, but will keep the compiler from taking too much time.)
unsigned SwitchCheckingInvocationThreshold = 200000;

/// Whether to delay checking that benefits from having the entire
/// module parsed, e.g., Objective-C method override checking.
bool DelayWholeModuleChecking = false;


/// If true, the time it takes to type-check each function will be dumped
/// to llvm::errs().
bool DebugTimeFunctionBodies = false;
Expand All @@ -497,11 +493,6 @@ namespace swift {
/// dumped to llvm::errs().
bool DebugTimeExpressions = false;

/// Indicate that the type checker is checking code that will be
/// immediately executed. This will suppress certain warnings
/// when executing scripts.
bool InImmediateMode = false;

/// Indicate that the type checker should skip type-checking non-inlinable
/// function bodies.
bool SkipNonInlinableFunctionBodies = false;
Expand Down
18 changes: 0 additions & 18 deletions lib/AST/TypeCheckRequests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1451,24 +1451,6 @@ void TypeCheckSourceFileRequest::cacheResult(evaluator::SideEffect) const {
FrontendStatsTracer tracer(Ctx.Stats, "AST verification");
// Verify the SourceFile.
swift::verify(*SF);

// Verify imported modules.
//
// Skip per-file verification in whole-module mode. Verifying imports
// between files could cause the importer to cache declarations without
// adding them to the ASTContext. This happens when the importer registers a
// declaration without a valid TypeChecker instance, as is the case during
// verification. A subsequent file may require that declaration to be fully
// imported (e.g. to synthesized a function body), but since it has already
// been cached, it will never be added to the ASTContext. The solution is to
// skip verification and avoid caching it.
#ifndef NDEBUG
if (!Ctx.TypeCheckerOpts.DelayWholeModuleChecking &&
SF->Kind != SourceFileKind::SIL &&
!Ctx.LangOpts.DebuggerSupport) {
Ctx.verifyAllLoadedModules();
}
#endif
}
}

Expand Down
34 changes: 10 additions & 24 deletions lib/Frontend/Frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,6 @@ bool CompilerInstance::setup(const CompilerInvocation &Invok) {
Invocation.getLangOptions().AttachCommentsToDecls = true;
}

// Set up the type checker options.
auto &typeCkOpts = Invocation.getTypeCheckerOptions();
if (isWholeModuleCompilation()) {
typeCkOpts.DelayWholeModuleChecking = true;
}
if (FrontendOptions::isActionImmediate(frontendOpts.RequestedAction)) {
typeCkOpts.InImmediateMode = true;
}

assert(Lexer::isIdentifier(Invocation.getModuleName()));

if (isInSILMode())
Expand Down Expand Up @@ -871,19 +862,16 @@ bool CompilerInstance::loadPartialModulesAndImplicitImports() {
return hadLoadError;
}

static void
forEachSourceFileIn(ModuleDecl *module,
llvm::function_ref<void(SourceFile &)> fn) {
for (auto fileName : module->getFiles()) {
if (auto SF = dyn_cast<SourceFile>(fileName))
fn(*SF);
}
}

void CompilerInstance::forEachFileToTypeCheck(
llvm::function_ref<void(SourceFile &)> fn) {
if (isWholeModuleCompilation()) {
forEachSourceFileIn(MainModule, [&](SourceFile &SF) { fn(SF); });
for (auto fileName : MainModule->getFiles()) {
auto *SF = dyn_cast<SourceFile>(fileName);
if (!SF) {
continue;
}
fn(*SF);
}
} else {
for (auto *SF : PrimarySourceFiles) {
fn(*SF);
Expand All @@ -892,11 +880,9 @@ void CompilerInstance::forEachFileToTypeCheck(
}

void CompilerInstance::finishTypeChecking() {
if (getASTContext().TypeCheckerOpts.DelayWholeModuleChecking) {
forEachSourceFileIn(MainModule, [&](SourceFile &SF) {
performWholeModuleTypeChecking(SF);
});
}
forEachFileToTypeCheck([](SourceFile &SF) {
performWholeModuleTypeChecking(SF);
});
}

SourceFile *CompilerInstance::createSourceFileForMainModule(
Expand Down
5 changes: 0 additions & 5 deletions lib/Sema/TypeChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,6 @@ TypeCheckSourceFileRequest::evaluate(Evaluator &eval, SourceFile *SF) const {
CheckInconsistentImplementationOnlyImportsRequest{SF->getParentModule()},
{});

// Checking that benefits from having the whole module available.
if (!Ctx.TypeCheckerOpts.DelayWholeModuleChecking) {
performWholeModuleTypeChecking(*SF);
}

// Perform various AST transforms we've been asked to perform.
if (!Ctx.hadError() && Ctx.LangOpts.DebuggerTestingTransform)
performDebuggerTestingTransform(*SF);
Expand Down