Skip to content

Commit ac68360

Browse files
committed
[NFC] Use an Iterator Again in WMO Type Checking
1 parent 0d117c1 commit ac68360

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

lib/Frontend/Frontend.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,19 +1168,13 @@ bool CompilerInstance::loadPartialModulesAndImplicitImports(
11681168
bool CompilerInstance::forEachFileToTypeCheck(
11691169
llvm::function_ref<bool(SourceFile &)> fn) {
11701170
if (isWholeModuleCompilation()) {
1171-
// FIXME: Do not refactor this to use an iterator as long as
1172-
// ModuleDecl::addFile is called during Sema. Synthesized files pushed
1173-
// during semantic analysis will cause iterator invalidation here.
1174-
// See notes in SourceFile::getOrCreateSynthesizedFile() for more.
1175-
unsigned i = 0;
1176-
while (i < getMainModule()->getFiles().size()) {
1177-
auto *SF = dyn_cast<SourceFile>(getMainModule()->getFiles()[i++]);
1171+
for (auto fileName : getMainModule()->getFiles()) {
1172+
auto *SF = dyn_cast<SourceFile>(fileName);
11781173
if (!SF) {
11791174
continue;
11801175
}
11811176
if (fn(*SF))
11821177
return true;
1183-
;
11841178
}
11851179
} else {
11861180
for (auto *SF : getPrimarySourceFiles()) {

lib/IRGen/IRGen.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,8 +1340,11 @@ static void performParallelIRGeneration(IRGenDescriptor desc) {
13401340

13411341
for (auto *File : M->getFiles()) {
13421342
if (auto *SF = dyn_cast<SourceFile>(File)) {
1343-
CurrentIGMPtr IGM = irgen.getGenModule(SF);
1344-
IGM->emitSourceFile(*SF);
1343+
{
1344+
CurrentIGMPtr IGM = irgen.getGenModule(SF);
1345+
IGM->emitSourceFile(*SF);
1346+
}
1347+
13451348
if (auto *synthSFU = File->getSynthesizedFile()) {
13461349
CurrentIGMPtr IGM = irgen.getGenModule(synthSFU);
13471350
IGM->emitSynthesizedFileUnit(*synthSFU);

0 commit comments

Comments
 (0)