Skip to content

Commit 3859ae6

Browse files
author
Nathan Hawes
committed
[Driver] Don't check input file existence if a -vfsoverlay arg is present.
Unlike the frontend, the driver doesn't account for any VFS overlays set up by the -vfsoverlay option when processing its input files. It also errors if any of those input files don't exist on the file system. This makes it impossible to use a file that only exists in the VFS as input to the driver, even though the same file would be handled without issue by the frontend. If the file doesn't exist even accounting for the VFS the frontend emits a missing file diagnostic, so this change just suppresses the existence check for inputs when a -vfsoverlay option is present. Resolves rdar://problem/72485443
1 parent e2bac38 commit 3859ae6

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/Driver/Driver.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,7 @@ void Driver::buildInputs(const ToolChain &TC,
12841284
const DerivedArgList &Args,
12851285
InputFileList &Inputs) const {
12861286
llvm::DenseMap<StringRef, StringRef> SourceFileNames;
1287+
bool HasVFS = Args.hasArg(options::OPT_vfsoverlay);
12871288

12881289
for (Arg *A : Args) {
12891290
if (A->getOption().getKind() == Option::InputClass) {
@@ -1305,7 +1306,7 @@ void Driver::buildInputs(const ToolChain &TC,
13051306
}
13061307
}
13071308

1308-
if (checkInputExistence(*this, Args, Diags, Value))
1309+
if (HasVFS || checkInputExistence(*this, Args, Diags, Value))
13091310
Inputs.push_back(std::make_pair(Ty, A));
13101311

13111312
if (Ty == file_types::TY_Swift) {

test/Driver/vfs.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@
77
// RUN: %swiftc_driver -driver-print-jobs -c -vfsoverlay overlay1.yaml -vfsoverlay overlay2.yaml -vfsoverlay overlay3.yaml %s | %FileCheck --check-prefix=CHECK-MULTIPLE %s
88

99
// CHECK-MULTIPLE: bin{{/|\\\\}}swift{{(-frontend|c)?(\.exe)?"?}} -frontend{{.*}}-c{{.*}}-vfsoverlay overlay1.yaml -vfsoverlay overlay2.yaml -vfsoverlay overlay3.yaml
10+
11+
// Verifies that input paths are not rejected prematurely when -vfsoverlay is present as they may exist on the vfs (which the frontend accounts for) even if they don't exist on the real file system.
12+
// RUN: not %swiftc_driver -driver-print-jobs -c %t/file-not-on-the-real-filesystem.swift
13+
// RUN: %swiftc_driver -driver-print-jobs -c -vfsoverlay overlay1.yaml %t/file-not-on-the-real-filesystem.swift

0 commit comments

Comments
 (0)