Skip to content

Commit 37e134c

Browse files
author
David Ungar
authored
Merge pull request #16126 from davidungar/exit-dont-crash-for-missing-output-file-map
Instead of crashing for bad output-file-map path, exit. Also print the path in the diagnostic.
2 parents f38192d + 2b89d1c commit 37e134c

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

include/swift/AST/DiagnosticsDriver.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ ERROR(error_cannot_specify__o_for_multiple_outputs,none,
6161
"cannot specify -o when generating multiple output files", ())
6262

6363
ERROR(error_unable_to_load_output_file_map, none,
64-
"unable to load output file map: %0", (StringRef))
64+
"unable to load output file map '%1': %0", (StringRef, StringRef))
6565

6666
ERROR(error_no_output_file_map_specified,none,
6767
"no output file map specified", ())

lib/Driver/Driver.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1832,7 +1832,8 @@ Driver::buildOutputFileMap(const llvm::opt::DerivedArgList &Args,
18321832
OutputFileMap::loadFromPath(A->getValue(), workingDirectory);
18331833
if (auto Err = OFM.takeError()) {
18341834
Diags.diagnose(SourceLoc(), diag::error_unable_to_load_output_file_map,
1835-
llvm::toString(std::move(Err)));
1835+
llvm::toString(std::move(Err)), A->getValue());
1836+
return None;
18361837
}
18371838
return *OFM;
18381839
}

test/Driver/missing-ofm.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Ensure that a bogus output-file-map path does not crash the driver,
2+
// but instead outputs a nice diagnostic.
3+
//
4+
// RUN: %empty-directory(%t)
5+
// RUN: not %swiftc_driver -c %S/../Inputs/empty.swift -output-file-map %t/something-which-should-not-exist.json 2>&1 | %FileCheck %s
6+
//
7+
// CHECK: error: unable to load output file map '{{.*}}/something-which-should-not-exist.json': No such file or directory
8+
// CHECK-NOT: Assertion failed

0 commit comments

Comments
 (0)