mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Extract emitReferenceDependenciesIfNeeded
This commit is contained in:
@@ -713,6 +713,22 @@ static Optional<bool> dumpASTIfNeeded(CompilerInvocation &Invocation,
|
|||||||
return Context.hadError();
|
return Context.hadError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void emitReferenceDependenciesIfNeeded(CompilerInvocation &Invocation,
|
||||||
|
CompilerInstance &Instance) {
|
||||||
|
if (Invocation.getFrontendOptions().ReferenceDependenciesFilePath.empty())
|
||||||
|
return;
|
||||||
|
if (Instance.getPrimarySourceFiles().empty()) {
|
||||||
|
Instance.getASTContext().Diags.diagnose(
|
||||||
|
SourceLoc(), diag::emit_reference_dependencies_without_primary_file);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (auto *SF : Instance.getPrimarySourceFiles()) {
|
||||||
|
emitReferenceDependencies(Instance.getASTContext().Diags, SF,
|
||||||
|
*Instance.getDependencyTracker(),
|
||||||
|
Invocation.getFrontendOptions());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
|
static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
|
||||||
CompilerInvocation &Invocation,
|
CompilerInvocation &Invocation,
|
||||||
std::unique_ptr<SILModule> SM,
|
std::unique_ptr<SILModule> SM,
|
||||||
@@ -750,8 +766,7 @@ static bool performCompile(CompilerInstance &Instance,
|
|||||||
return compileLLVMIR(Invocation, Instance, Stats);
|
return compileLLVMIR(Invocation, Instance, Stats);
|
||||||
|
|
||||||
ReferencedNameTracker nameTracker;
|
ReferencedNameTracker nameTracker;
|
||||||
bool shouldTrackReferences = !opts.ReferenceDependenciesFilePath.empty();
|
if (!opts.ReferenceDependenciesFilePath.empty())
|
||||||
if (shouldTrackReferences)
|
|
||||||
Instance.setReferencedNameTracker(&nameTracker);
|
Instance.setReferencedNameTracker(&nameTracker);
|
||||||
|
|
||||||
if (FrontendOptions::shouldActionOnlyParse(Action))
|
if (FrontendOptions::shouldActionOnlyParse(Action))
|
||||||
@@ -801,15 +816,7 @@ static bool performCompile(CompilerInstance &Instance,
|
|||||||
(void)emitMakeDependencies(Context.Diags, *Instance.getDependencyTracker(),
|
(void)emitMakeDependencies(Context.Diags, *Instance.getDependencyTracker(),
|
||||||
opts);
|
opts);
|
||||||
|
|
||||||
if (shouldTrackReferences) {
|
emitReferenceDependenciesIfNeeded(Invocation, Instance);
|
||||||
if (Instance.getPrimarySourceFiles().empty())
|
|
||||||
Context.Diags.diagnose(
|
|
||||||
SourceLoc(), diag::emit_reference_dependencies_without_primary_file);
|
|
||||||
for (auto *SF : Instance.getPrimarySourceFiles()) {
|
|
||||||
emitReferenceDependencies(Context.Diags, SF,
|
|
||||||
*Instance.getDependencyTracker(), opts);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
(void)emitLoadedModuleTraceIfNeeded(Context, *Instance.getDependencyTracker(),
|
(void)emitLoadedModuleTraceIfNeeded(Context, *Instance.getDependencyTracker(),
|
||||||
opts);
|
opts);
|
||||||
|
|||||||
Reference in New Issue
Block a user