Skip to content

[Batch Mode] Add frontend check to ensure that all primaries are present in the supplementary output filemap. #15433

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
merged 1 commit into from
Mar 22, 2018
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
3 changes: 3 additions & 0 deletions include/swift/AST/DiagnosticsFrontend.def
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ ERROR(error_underlying_module_not_found,none,
ERROR(error_unable_to_load_supplementary_output_file_map, none,
"unable to load supplementary output file map '%0': %1", (StringRef, StringRef))

ERROR(error_missing_entry_in_supplementary_output_file_map, none,
"supplementary output file map '%0' is missing an entry for '%1' (this likely indicates a compiler issue; please file a bug report)", (StringRef, StringRef))

ERROR(error_repl_requires_no_input_files,none,
"REPL mode requires no input files", ())
ERROR(error_mode_requires_one_input_file,none,
Expand Down
1 change: 1 addition & 0 deletions include/swift/Frontend/ArgsToFrontendOutputsConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <vector>

namespace swift {
class OutputFileMap;

/// Given the command line arguments and information about the inputs,
/// Fill in all the information in FrontendInputsAndOutputs.
Expand Down
10 changes: 10 additions & 0 deletions lib/Frontend/ArgsToFrontendOutputsConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -518,13 +518,23 @@ SupplementaryOutputPathsComputer::readSupplementaryOutputFileMap() const {
}

std::vector<SupplementaryOutputPaths> outputPaths;
bool hadError = false;
InputsAndOutputs.forEachInputProducingSupplementaryOutput(
[&](const InputFile &input) -> bool {
const TypeToPathMap *mapForInput =
OFM->getOutputMapForInput(input.file());
if (!mapForInput) {
Diags.diagnose(
SourceLoc(),
diag::error_missing_entry_in_supplementary_output_file_map,
supplementaryFileMapPath, input.file());
hadError = true;
}
outputPaths.push_back(createFromTypeToPathMap(mapForInput));
return false;
});
if (hadError)
return None;

return outputPaths;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"main.swift":
object: "main.o"
dependencies: "main.d"
diagnostics: "main.dia"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// RUN: %empty-directory(%t)
// RUN: echo 'print("Hello, World!")' >%t/main.swift
// RUN: touch %t/file-01.swift
// RUN: (cd %t && not %target-swift-frontend -parse -primary-file main.swift -primary-file file-01.swift -supplementary-output-file-map %S/Inputs/supplementary_output_filemap_missing_a_primary.yaml >%t/errs.txt 2>&1)
// RUN: %FileCheck %s <%t/errs.txt
// CHECK: error: supplementary output file map '{{.*}}supplementary_output_filemap_missing_a_primary.yaml' is missing an entry for 'file-01.swift' (this likely indicates a compiler issue; please file a bug report)