Skip to content

Instead of crashing for bad output-file-map path, exit. Also print the path in the diagnostic. rdar://39660680 #16126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/swift/AST/DiagnosticsDriver.def
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ ERROR(error_cannot_specify__o_for_multiple_outputs,none,
"cannot specify -o when generating multiple output files", ())

ERROR(error_unable_to_load_output_file_map, none,
"unable to load output file map: %0", (StringRef))
"unable to load output file map '%1': %0", (StringRef, StringRef))

ERROR(error_no_output_file_map_specified,none,
"no output file map specified", ())
Expand Down
3 changes: 2 additions & 1 deletion lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1832,7 +1832,8 @@ Driver::buildOutputFileMap(const llvm::opt::DerivedArgList &Args,
OutputFileMap::loadFromPath(A->getValue(), workingDirectory);
if (auto Err = OFM.takeError()) {
Diags.diagnose(SourceLoc(), diag::error_unable_to_load_output_file_map,
llvm::toString(std::move(Err)));
llvm::toString(std::move(Err)), A->getValue());
return None;
}
return *OFM;
}
Expand Down
8 changes: 8 additions & 0 deletions test/Driver/missing-ofm.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Ensure that a bogus output-file-map path does not crash the driver,
// but instead outputs a nice diagnostic.
//
// RUN: %empty-directory(%t)
// RUN: not %swiftc_driver -c %S/../Inputs/empty.swift -output-file-map %t/something-which-should-not-exist.json 2>&1 | %FileCheck %s
//
// CHECK: error: unable to load output file map '{{.*}}/something-which-should-not-exist.json': No such file or directory
// CHECK-NOT: Assertion failed