[NFC] Remove forEachSourceFileIn

We actually wanted to use forEachFileToTypeCheck, which will restrict
the source files we analyze to just the given primaries in incremental
mode, and the whole module's source files otherwise.
This commit is contained in:
Robert Widmann
2020-05-18 20:07:35 -07:00
parent 921180fff0
commit 854d6ee122

View File

@@ -862,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);
@@ -883,7 +880,7 @@ void CompilerInstance::forEachFileToTypeCheck(
}
void CompilerInstance::finishTypeChecking() {
forEachSourceFileIn(MainModule, [&](SourceFile &SF) {
forEachFileToTypeCheck([](SourceFile &SF) {
performWholeModuleTypeChecking(SF);
});
}