mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
suppress non-primary errors if there is no responsible primary
This commit is contained in:
@@ -1540,12 +1540,30 @@ createDispatchingDiagnosticConsumerIfNeeded(
|
||||
|
||||
inputsAndOutputs.forEachInputProducingSupplementaryOutput(
|
||||
[&](const InputFile &input) -> bool {
|
||||
if (auto consumer = maybeCreateConsumerForDiagnosticsFrom(input)) {
|
||||
assert(consumer && "Consumer should always be non-null");
|
||||
if (auto consumer = maybeCreateConsumerForDiagnosticsFrom(input))
|
||||
subconsumers.emplace_back(input.file(), std::move(consumer));
|
||||
}
|
||||
return false;
|
||||
});
|
||||
// For batch mode, the compiler must sometimes swallow diagnostics pertaining to
|
||||
// non-primary files in order to avoid Xcode showing the same diagnostic
|
||||
// multiple times. So, create a diagnostic "eater" for those non-primary
|
||||
// files.
|
||||
//
|
||||
// This routine gets called for \c createJSONFixItDiagnosticConsumerIfNeeded
|
||||
// in cases where no primary subconsumers are created.
|
||||
// Don't bother to create non-primary subconsumers if there aren't any primary
|
||||
// ones.
|
||||
//
|
||||
// To avoid introducing bugs into WMO or single-file modes, test for multiple
|
||||
// primaries.
|
||||
if (!subconsumers.empty() && inputsAndOutputs.hasMultiplePrimaryInputs()) {
|
||||
inputsAndOutputs.forEachNonPrimaryInput(
|
||||
[&](const InputFile &input) -> bool {
|
||||
subconsumers.emplace_back(input.file(), nullptr);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
return FileSpecificDiagnosticConsumer::consolidateSubconsumers(subconsumers);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user