Skip to content

Commit 824122b

Browse files
author
David Ungar
committed
Fix for emit_reference_dependencies_without_primary_file warning required after changes to introduce multiple primary files to CompilerInstance.
Revealed by test Frontend/dependencies.swift.
1 parent a243ffb commit 824122b

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,9 @@ static bool performCompile(CompilerInstance &Instance,
734734
opts);
735735

736736
if (shouldTrackReferences) {
737+
if (Instance.getPrimarySourceFiles().empty())
738+
Context.Diags.diagnose(
739+
SourceLoc(), diag::emit_reference_dependencies_without_primary_file);
737740
for (auto *SF : Instance.getPrimarySourceFiles()) {
738741
emitReferenceDependencies(Context.Diags, SF,
739742
*Instance.getDependencyTracker(), opts);

lib/FrontendTool/ReferenceDependencies.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,7 @@ bool swift::emitReferenceDependencies(DiagnosticEngine &diags,
126126
SourceFile *SF,
127127
DependencyTracker &depTracker,
128128
const FrontendOptions &opts) {
129-
if (!SF) {
130-
diags.diagnose(SourceLoc(),
131-
diag::emit_reference_dependencies_without_primary_file);
132-
return true;
133-
}
129+
assert(SF && "Cannot emit reference dependencies without a SourceFile");
134130

135131
// Before writing to the dependencies file path, preserve any previous file
136132
// that may have been there. No error handling -- this is just a nicety, it

0 commit comments

Comments
 (0)