@@ -395,8 +395,10 @@ public struct Driver {
395395 guard let moduleOutput = moduleOutputInfo. output else {
396396 return nil
397397 }
398- return TypedVirtualPath ( file: VirtualPath . lookup ( moduleOutput. outputPath)
399- . replacingExtension ( with: . jsonABIBaseline) . intern ( ) , type: . jsonABIBaseline)
398+ guard let path = try ? VirtualPath . lookup ( moduleOutput. outputPath) . replacingExtension ( with: . jsonABIBaseline) else {
399+ return nil
400+ }
401+ return TypedVirtualPath ( file: path. intern ( ) , type: . jsonABIBaseline)
400402 } ( )
401403
402404 public static func isOptionFound( _ opt: String , allOpts: Set < String > ) -> Bool {
@@ -513,7 +515,7 @@ public struct Driver {
513515 // Compute the working directory.
514516 workingDirectory = try parsedOptions. getLastArgument ( . workingDirectory) . map { workingDirectoryArg in
515517 let cwd = fileSystem. currentWorkingDirectory
516- return try cwd. map { AbsolutePath ( workingDirectoryArg. asSingle, relativeTo: $0) } ?? AbsolutePath ( validating: workingDirectoryArg. asSingle)
518+ return try cwd. map { try AbsolutePath ( validating : workingDirectoryArg. asSingle, relativeTo: $0) } ?? AbsolutePath ( validating: workingDirectoryArg. asSingle)
517519 }
518520
519521 // Apply the working directory to the parsed options.
@@ -823,7 +825,7 @@ public struct Driver {
823825 // with private Clang modules.
824826 if let swiftInterfacePath = self . swiftInterfacePath,
825827 givenPrivateInterfacePath == nil {
826- self . swiftPrivateInterfacePath = VirtualPath . lookup ( swiftInterfacePath)
828+ self . swiftPrivateInterfacePath = try VirtualPath . lookup ( swiftInterfacePath)
827829 . replacingExtension ( with: . privateSwiftInterface) . intern ( )
828830 } else {
829831 self . swiftPrivateInterfacePath = givenPrivateInterfacePath
@@ -1167,7 +1169,10 @@ extension Driver {
11671169 ) -> AbsolutePath ? {
11681170 let responseFile : AbsolutePath
11691171 if let basePath = basePath {
1170- responseFile = AbsolutePath ( path, relativeTo: basePath)
1172+ guard let absolutePath = try ? AbsolutePath ( validating: path, relativeTo: basePath) else {
1173+ return nil
1174+ }
1175+ responseFile = absolutePath
11711176 } else {
11721177 guard let absolutePath = try ? AbsolutePath ( validating: path) else {
11731178 return nil
@@ -1741,7 +1746,7 @@ extension Driver {
17411746 /// Apply the given working directory to all paths in the parsed options.
17421747 private static func applyWorkingDirectory( _ workingDirectory: AbsolutePath ,
17431748 to parsedOptions: inout ParsedOptions ) throws {
1744- parsedOptions. forEachModifying { parsedOption in
1749+ try parsedOptions. forEachModifying { parsedOption in
17451750 // Only translate options whose arguments are paths.
17461751 if !parsedOption. option. attributes. contains ( . argumentIsPath) { return }
17471752
@@ -1754,12 +1759,12 @@ extension Driver {
17541759 if arg == " - " {
17551760 translatedArgument = parsedOption. argument
17561761 } else {
1757- translatedArgument = . single( AbsolutePath ( arg, relativeTo: workingDirectory) . pathString)
1762+ translatedArgument = . single( try AbsolutePath ( validating : arg, relativeTo: workingDirectory) . pathString)
17581763 }
17591764
17601765 case . multiple( let args) :
1761- translatedArgument = . multiple( args. map { arg in
1762- AbsolutePath ( arg, relativeTo: workingDirectory) . pathString
1766+ translatedArgument = . multiple( try args. map { arg in
1767+ try AbsolutePath ( validating : arg, relativeTo: workingDirectory) . pathString
17631768 } )
17641769 }
17651770
@@ -2400,7 +2405,7 @@ extension Driver {
24002405
24012406 // Use working directory if specified
24022407 if let moduleRelative = moduleOutputPath. relativePath {
2403- moduleOutputPath = Driver . useWorkingDirectory ( moduleRelative, workingDirectory)
2408+ moduleOutputPath = try Driver . useWorkingDirectory ( moduleRelative, workingDirectory)
24042409 }
24052410
24062411 switch moduleOutputKind! {
@@ -2500,8 +2505,8 @@ extension Driver {
25002505 // FIXME: TSC should provide a better utility for this.
25012506 if let absPath = try ? AbsolutePath ( validating: sdkPath) {
25022507 path = absPath
2503- } else if let cwd = fileSystem. currentWorkingDirectory {
2504- path = AbsolutePath ( sdkPath , relativeTo : cwd )
2508+ } else if let cwd = fileSystem. currentWorkingDirectory, let absPath = try ? AbsolutePath ( validating : sdkPath , relativeTo : cwd ) {
2509+ path = absPath
25052510 } else {
25062511 diagnosticsEngine. emit ( . warning_no_such_sdk( sdkPath) )
25072512 return nil
@@ -2585,7 +2590,7 @@ extension Driver {
25852590 return nil
25862591 }
25872592
2588- if let outputPath = outputFileMap? . existingOutput ( inputFile: input, outputType: . pch) {
2593+ if let outputPath = try outputFileMap? . existingOutput ( inputFile: input, outputType: . pch) {
25892594 return outputPath
25902595 }
25912596
@@ -2689,9 +2694,11 @@ extension Driver {
26892694 if let profileArgs = parsedOptions. getLastArgument ( . profileUse) ? . asMultiple,
26902695 let workingDirectory = workingDirectory ?? fileSystem. currentWorkingDirectory {
26912696 for profilingData in profileArgs {
2692- if !fileSystem. exists ( AbsolutePath ( profilingData,
2693- relativeTo: workingDirectory) ) {
2694- diagnosticEngine. emit ( Error . missingProfilingData ( profilingData) )
2697+ if let path = try ? AbsolutePath ( validating: profilingData,
2698+ relativeTo: workingDirectory) {
2699+ if !fileSystem. exists ( path) {
2700+ diagnosticEngine. emit ( Error . missingProfilingData ( profilingData) )
2701+ }
26952702 }
26962703 }
26972704 }
@@ -3065,7 +3072,7 @@ extension Driver {
30653072 // If this is a single-file compile and there is an entry in the
30663073 // output file map, use that.
30673074 if compilerMode. isSingleCompilation,
3068- let singleOutputPath = outputFileMap? . existingOutputForSingleInput (
3075+ let singleOutputPath = try outputFileMap? . existingOutputForSingleInput (
30693076 outputType: type) {
30703077 return singleOutputPath
30713078 }
@@ -3074,23 +3081,23 @@ extension Driver {
30743081 // primary output type is a .swiftmodule and we are using the emit-module-separately
30753082 // flow, then also consider single output paths specified in the output file-map.
30763083 if compilerOutputType == . swiftModule && emitModuleSeparately,
3077- let singleOutputPath = outputFileMap? . existingOutputForSingleInput (
3084+ let singleOutputPath = try outputFileMap? . existingOutputForSingleInput (
30783085 outputType: type) {
30793086 return singleOutputPath
30803087 }
30813088
30823089 // Emit-module serialized diagnostics are always specified as a single-output
30833090 // file
30843091 if type == . emitModuleDiagnostics,
3085- let singleOutputPath = outputFileMap? . existingOutputForSingleInput (
3092+ let singleOutputPath = try outputFileMap? . existingOutputForSingleInput (
30863093 outputType: type) {
30873094 return singleOutputPath
30883095 }
30893096
30903097 // Emit-module discovered dependencies are always specified as a single-output
30913098 // file
30923099 if type == . emitModuleDependencies,
3093- let path = outputFileMap? . existingOutputForSingleInput ( outputType: type) {
3100+ let path = try outputFileMap? . existingOutputForSingleInput ( outputType: type) {
30943101 return path
30953102 }
30963103
@@ -3113,7 +3120,7 @@ extension Driver {
31133120 // synthesize a path from the master swift dependency path. This is
31143121 // important as we may otherwise emit this file at the location where the
31153122 // driver was invoked, which is normally the root of the package.
3116- if let path = outputFileMap? . existingOutputForSingleInput ( outputType: . swiftDeps) {
3123+ if let path = try outputFileMap? . existingOutputForSingleInput ( outputType: . swiftDeps) {
31173124 return VirtualPath . lookup ( path)
31183125 . parentDirectory
31193126 . appending ( component: " \( moduleName) . \( type. rawValue) " )
@@ -3230,7 +3237,7 @@ extension Driver {
32303237 // If this is a single-file compile and there is an entry in the
32313238 // output file map, use that.
32323239 if compilerMode. isSingleCompilation,
3233- let singleOutputPath = outputFileMap? . existingOutputForSingleInput (
3240+ let singleOutputPath = try outputFileMap? . existingOutputForSingleInput (
32343241 outputType: type) {
32353242 return singleOutputPath
32363243 }
@@ -3249,7 +3256,7 @@ extension Driver {
32493256 parentPath = VirtualPath . lookup ( moduleOutputPath) . parentDirectory
32503257 }
32513258
3252- return parentPath
3259+ return try parentPath
32533260 . appending ( component: VirtualPath . lookup ( moduleOutputPath) . basename)
32543261 . replacingExtension ( with: type)
32553262 . intern ( )
0 commit comments