Skip to content

Commit 3376ca7

Browse files
author
David Ungar
committed
Add frontend check to ensure that all primaries are present in the supplementary output filemap.
1 parent 807dd58 commit 3376ca7

5 files changed

+24
-0
lines changed

include/swift/AST/DiagnosticsFrontend.def

+3
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ ERROR(error_underlying_module_not_found,none,
136136
ERROR(error_unable_to_load_supplementary_output_file_map, none,
137137
"unable to load supplementary output file map '%0': %1", (StringRef, StringRef))
138138

139+
ERROR(error_missing_entry_in_supplementary_output_file_map, none,
140+
"supplementary output file map '%0' is missing an entry for '%1' (this likely indicates a compiler issue; please file a bug report)", (StringRef, StringRef))
141+
139142
ERROR(error_repl_requires_no_input_files,none,
140143
"REPL mode requires no input files", ())
141144
ERROR(error_mode_requires_one_input_file,none,

include/swift/Frontend/ArgsToFrontendOutputsConverter.h

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <vector>
2525

2626
namespace swift {
27+
class OutputFileMap;
2728

2829
/// Given the command line arguments and information about the inputs,
2930
/// Fill in all the information in FrontendInputsAndOutputs.

lib/Frontend/ArgsToFrontendOutputsConverter.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -518,13 +518,23 @@ SupplementaryOutputPathsComputer::readSupplementaryOutputFileMap() const {
518518
}
519519

520520
std::vector<SupplementaryOutputPaths> outputPaths;
521+
bool hadError = false;
521522
InputsAndOutputs.forEachInputProducingSupplementaryOutput(
522523
[&](const InputFile &input) -> bool {
523524
const TypeToPathMap *mapForInput =
524525
OFM->getOutputMapForInput(input.file());
526+
if (!mapForInput) {
527+
Diags.diagnose(
528+
SourceLoc(),
529+
diag::error_missing_entry_in_supplementary_output_file_map,
530+
supplementaryFileMapPath, input.file());
531+
hadError = true;
532+
}
525533
outputPaths.push_back(createFromTypeToPathMap(mapForInput));
526534
return false;
527535
});
536+
if (hadError)
537+
return None;
528538

529539
return outputPaths;
530540
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"main.swift":
2+
object: "main.o"
3+
dependencies: "main.d"
4+
diagnostics: "main.dia"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: echo 'print("Hello, World!")' >%t/main.swift
3+
// RUN: touch %t/file-01.swift
4+
// 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)
5+
// RUN: %FileCheck %s <%t/errs.txt
6+
// 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)

0 commit comments

Comments
 (0)