Skip to content

Commit 2cf731b

Browse files
author
David Ungar
authored
Merge pull request #383 from davidungar/encapsulate-local-output-filemap
[NFC] Encapsulate local outputFileMap to forestall bugs
2 parents aa87d8d + adfeb40 commit 2cf731b

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -370,25 +370,27 @@ public struct Driver {
370370
guard let modTime = try? fileSystem
371371
.getFileInfo($0.file).modTime else { return nil }
372372
return ($0, modTime)
373-
})
374-
375-
let outputFileMap: OutputFileMap?
376-
// Initialize an empty output file map, which will be populated when we start creating jobs.
377-
if let outputFileMapArg = parsedOptions.getLastArgument(.outputFileMap)?.asSingle {
378-
do {
379-
let path = try VirtualPath(path: outputFileMapArg)
380-
outputFileMap = try .load(fileSystem: fileSystem, file: path, diagnosticEngine: diagnosticEngine)
381-
} catch {
382-
throw Error.unableToLoadOutputFileMap(outputFileMapArg)
373+
})
374+
375+
do {
376+
let outputFileMap: OutputFileMap?
377+
// Initialize an empty output file map, which will be populated when we start creating jobs.
378+
if let outputFileMapArg = parsedOptions.getLastArgument(.outputFileMap)?.asSingle {
379+
do {
380+
let path = try VirtualPath(path: outputFileMapArg)
381+
outputFileMap = try .load(fileSystem: fileSystem, file: path, diagnosticEngine: diagnosticEngine)
382+
} catch {
383+
throw Error.unableToLoadOutputFileMap(outputFileMapArg)
384+
}
385+
} else {
386+
outputFileMap = nil
383387
}
384-
} else {
385-
outputFileMap = nil
386-
}
387388

388-
if let workingDirectory = self.workingDirectory {
389-
self.outputFileMap = outputFileMap?.resolveRelativePaths(relativeTo: workingDirectory)
390-
} else {
391-
self.outputFileMap = outputFileMap
389+
if let workingDirectory = self.workingDirectory {
390+
self.outputFileMap = outputFileMap?.resolveRelativePaths(relativeTo: workingDirectory)
391+
} else {
392+
self.outputFileMap = outputFileMap
393+
}
392394
}
393395

394396
self.fileListThreshold = try Self.computeFileListThreshold(&self.parsedOptions, diagnosticsEngine: diagnosticsEngine)

0 commit comments

Comments
 (0)