Skip to content

Commit aaf51f7

Browse files
author
David Ungar
committed
Addressing review comments.
1 parent 34f423f commit aaf51f7

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

lib/AST/DiagnosticConsumer.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ void FileSpecificDiagnosticConsumer::computeConsumersOrderedByRange(
7171
Optional<unsigned> bufferID = SM.getIDForBufferIdentifier(pair.first);
7272
assert(bufferID.hasValue() && "consumer registered for unknown file");
7373
CharSourceRange range = SM.getRangeForBuffer(bufferID.getValue());
74-
ConsumersOrderedByRange.emplace_back(range, pair.second ? pair.second.get()
75-
: nullptr);
74+
ConsumersOrderedByRange.emplace_back(range, pair.second.get());
7675
}
7776

7877
// Sort the "map" by buffer /end/ location, for use with std::lower_bound
@@ -186,9 +185,8 @@ void FileSpecificDiagnosticConsumer::handleDiagnostic(
186185
}
187186
} else if (DiagnosticConsumer *c = specificConsumer.getValue())
188187
c->handleDiagnostic(SM, Loc, Kind, FormatString, FormatArgs, Info);
189-
else {
190-
/// suppress non-primary diagnostic in batch mode
191-
}
188+
else
189+
; // Suppress non-primary diagnostic in batch mode.
192190
}
193191

194192
bool FileSpecificDiagnosticConsumer::finishProcessing() {

lib/Frontend/FrontendInputsAndOutputs.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,18 @@ bool FrontendInputsAndOutputs::forEachInputProducingSupplementaryOutput(
373373

374374
bool FrontendInputsAndOutputs::forEachInputNotProducingSupplementaryOutput(
375375
llvm::function_ref<bool(const InputFile &)> fn) const {
376-
// If no primary inputs, compiler is in whole-module-optimzation mode, and
377-
// every input can produce supplementary outputs.
378-
return hasPrimaryInputs() ? forEachNonPrimaryInput(fn) : false;
376+
if (hasPrimaryInputs())
377+
return forEachNonPrimaryInput(fn);
378+
// If no primary inputs, compiler is in whole-module-optimization mode, and
379+
// only the first input can produce supplementary outputs, although all
380+
// inputs may contribute.
381+
bool isFirst = true;
382+
return forEachNonPrimaryInput([&](const InputFile &f) -> bool {
383+
if (!isFirst)
384+
return fn(f);
385+
isFirst = false;
386+
return false;
387+
});
379388
}
380389

381390
bool FrontendInputsAndOutputs::hasSupplementaryOutputPath(

test/Misc/serialized-diagnostics-batch-mode-nonprimary-suppression.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,4 @@
2323

2424

2525
func test(x: SomeType) {
26-
// CHECK-MAIN-DAG: serialized-diagnostics-batch-mode.swift:[[@LINE]]:3: error: use of unresolved identifier 'nonexistent'
27-
// CHECK-STDERR-DAG: serialized-diagnostics-batch-mode.swift:[[@LINE-1]]:3: error: use of unresolved identifier 'nonexistent'
28-
29-
// The other file has a similar call.
30-
// CHECK-HELPER-DAG: serialized-diagnostics-batch-mode-helper.swift:{{[0-9]+}}:3: error: use of unresolved identifier 'nonexistent'
31-
// CHECK-STDERR-DAG: serialized-diagnostics-batch-mode-helper.swift:{{[0-9]+}}:3: error: use of unresolved identifier 'nonexistent'
3226
}

0 commit comments

Comments
 (0)