@@ -395,8 +395,10 @@ public struct Driver {
395
395
guard let moduleOutput = moduleOutputInfo. output else {
396
396
return nil
397
397
}
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)
400
402
} ( )
401
403
402
404
public static func isOptionFound( _ opt: String , allOpts: Set < String > ) -> Bool {
@@ -513,7 +515,7 @@ public struct Driver {
513
515
// Compute the working directory.
514
516
workingDirectory = try parsedOptions. getLastArgument ( . workingDirectory) . map { workingDirectoryArg in
515
517
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)
517
519
}
518
520
519
521
// Apply the working directory to the parsed options.
@@ -823,7 +825,7 @@ public struct Driver {
823
825
// with private Clang modules.
824
826
if let swiftInterfacePath = self . swiftInterfacePath,
825
827
givenPrivateInterfacePath == nil {
826
- self . swiftPrivateInterfacePath = VirtualPath . lookup ( swiftInterfacePath)
828
+ self . swiftPrivateInterfacePath = try VirtualPath . lookup ( swiftInterfacePath)
827
829
. replacingExtension ( with: . privateSwiftInterface) . intern ( )
828
830
} else {
829
831
self . swiftPrivateInterfacePath = givenPrivateInterfacePath
@@ -1167,7 +1169,10 @@ extension Driver {
1167
1169
) -> AbsolutePath ? {
1168
1170
let responseFile : AbsolutePath
1169
1171
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
1171
1176
} else {
1172
1177
guard let absolutePath = try ? AbsolutePath ( validating: path) else {
1173
1178
return nil
@@ -1741,7 +1746,7 @@ extension Driver {
1741
1746
/// Apply the given working directory to all paths in the parsed options.
1742
1747
private static func applyWorkingDirectory( _ workingDirectory: AbsolutePath ,
1743
1748
to parsedOptions: inout ParsedOptions ) throws {
1744
- parsedOptions. forEachModifying { parsedOption in
1749
+ try parsedOptions. forEachModifying { parsedOption in
1745
1750
// Only translate options whose arguments are paths.
1746
1751
if !parsedOption. option. attributes. contains ( . argumentIsPath) { return }
1747
1752
@@ -1754,12 +1759,12 @@ extension Driver {
1754
1759
if arg == " - " {
1755
1760
translatedArgument = parsedOption. argument
1756
1761
} else {
1757
- translatedArgument = . single( AbsolutePath ( arg, relativeTo: workingDirectory) . pathString)
1762
+ translatedArgument = . single( try AbsolutePath ( validating : arg, relativeTo: workingDirectory) . pathString)
1758
1763
}
1759
1764
1760
1765
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
1763
1768
} )
1764
1769
}
1765
1770
@@ -2400,7 +2405,7 @@ extension Driver {
2400
2405
2401
2406
// Use working directory if specified
2402
2407
if let moduleRelative = moduleOutputPath. relativePath {
2403
- moduleOutputPath = Driver . useWorkingDirectory ( moduleRelative, workingDirectory)
2408
+ moduleOutputPath = try Driver . useWorkingDirectory ( moduleRelative, workingDirectory)
2404
2409
}
2405
2410
2406
2411
switch moduleOutputKind! {
@@ -2500,8 +2505,8 @@ extension Driver {
2500
2505
// FIXME: TSC should provide a better utility for this.
2501
2506
if let absPath = try ? AbsolutePath ( validating: sdkPath) {
2502
2507
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
2505
2510
} else {
2506
2511
diagnosticsEngine. emit ( . warning_no_such_sdk( sdkPath) )
2507
2512
return nil
@@ -2585,7 +2590,7 @@ extension Driver {
2585
2590
return nil
2586
2591
}
2587
2592
2588
- if let outputPath = outputFileMap? . existingOutput ( inputFile: input, outputType: . pch) {
2593
+ if let outputPath = try outputFileMap? . existingOutput ( inputFile: input, outputType: . pch) {
2589
2594
return outputPath
2590
2595
}
2591
2596
@@ -2689,9 +2694,11 @@ extension Driver {
2689
2694
if let profileArgs = parsedOptions. getLastArgument ( . profileUse) ? . asMultiple,
2690
2695
let workingDirectory = workingDirectory ?? fileSystem. currentWorkingDirectory {
2691
2696
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
+ }
2695
2702
}
2696
2703
}
2697
2704
}
@@ -3065,7 +3072,7 @@ extension Driver {
3065
3072
// If this is a single-file compile and there is an entry in the
3066
3073
// output file map, use that.
3067
3074
if compilerMode. isSingleCompilation,
3068
- let singleOutputPath = outputFileMap? . existingOutputForSingleInput (
3075
+ let singleOutputPath = try outputFileMap? . existingOutputForSingleInput (
3069
3076
outputType: type) {
3070
3077
return singleOutputPath
3071
3078
}
@@ -3074,23 +3081,23 @@ extension Driver {
3074
3081
// primary output type is a .swiftmodule and we are using the emit-module-separately
3075
3082
// flow, then also consider single output paths specified in the output file-map.
3076
3083
if compilerOutputType == . swiftModule && emitModuleSeparately,
3077
- let singleOutputPath = outputFileMap? . existingOutputForSingleInput (
3084
+ let singleOutputPath = try outputFileMap? . existingOutputForSingleInput (
3078
3085
outputType: type) {
3079
3086
return singleOutputPath
3080
3087
}
3081
3088
3082
3089
// Emit-module serialized diagnostics are always specified as a single-output
3083
3090
// file
3084
3091
if type == . emitModuleDiagnostics,
3085
- let singleOutputPath = outputFileMap? . existingOutputForSingleInput (
3092
+ let singleOutputPath = try outputFileMap? . existingOutputForSingleInput (
3086
3093
outputType: type) {
3087
3094
return singleOutputPath
3088
3095
}
3089
3096
3090
3097
// Emit-module discovered dependencies are always specified as a single-output
3091
3098
// file
3092
3099
if type == . emitModuleDependencies,
3093
- let path = outputFileMap? . existingOutputForSingleInput ( outputType: type) {
3100
+ let path = try outputFileMap? . existingOutputForSingleInput ( outputType: type) {
3094
3101
return path
3095
3102
}
3096
3103
@@ -3113,7 +3120,7 @@ extension Driver {
3113
3120
// synthesize a path from the master swift dependency path. This is
3114
3121
// important as we may otherwise emit this file at the location where the
3115
3122
// 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) {
3117
3124
return VirtualPath . lookup ( path)
3118
3125
. parentDirectory
3119
3126
. appending ( component: " \( moduleName) . \( type. rawValue) " )
@@ -3230,7 +3237,7 @@ extension Driver {
3230
3237
// If this is a single-file compile and there is an entry in the
3231
3238
// output file map, use that.
3232
3239
if compilerMode. isSingleCompilation,
3233
- let singleOutputPath = outputFileMap? . existingOutputForSingleInput (
3240
+ let singleOutputPath = try outputFileMap? . existingOutputForSingleInput (
3234
3241
outputType: type) {
3235
3242
return singleOutputPath
3236
3243
}
@@ -3249,7 +3256,7 @@ extension Driver {
3249
3256
parentPath = VirtualPath . lookup ( moduleOutputPath) . parentDirectory
3250
3257
}
3251
3258
3252
- return parentPath
3259
+ return try parentPath
3253
3260
. appending ( component: VirtualPath . lookup ( moduleOutputPath) . basename)
3254
3261
. replacingExtension ( with: type)
3255
3262
. intern ( )
0 commit comments