Skip to content

Commit adfeb40

Browse files
author
David Ungar
committed
Encapsulate local outputFileMap to forestall bugs
1 parent cf36366 commit adfeb40

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
@@ -369,25 +369,27 @@ public struct Driver {
369369
guard let modTime = try? fileSystem
370370
.getFileInfo($0.file).modTime else { return nil }
371371
return ($0, modTime)
372-
})
373-
374-
let outputFileMap: OutputFileMap?
375-
// Initialize an empty output file map, which will be populated when we start creating jobs.
376-
if let outputFileMapArg = parsedOptions.getLastArgument(.outputFileMap)?.asSingle {
377-
do {
378-
let path = try VirtualPath(path: outputFileMapArg)
379-
outputFileMap = try .load(fileSystem: fileSystem, file: path, diagnosticEngine: diagnosticEngine)
380-
} catch {
381-
throw Error.unableToLoadOutputFileMap(outputFileMapArg)
372+
})
373+
374+
do {
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)
383+
}
384+
} else {
385+
outputFileMap = nil
382386
}
383-
} else {
384-
outputFileMap = nil
385-
}
386387

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

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

0 commit comments

Comments
 (0)