Skip to content

Commit bddcda6

Browse files
committed
[Frontend] Factor out setupDependencyTrackerIfNeeded
And call from `CompilerInstance::setup`.
1 parent 0893f08 commit bddcda6

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

include/swift/Frontend/Frontend.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,7 @@ class CompilerInstance {
582582
bool setUpASTContextIfNeeded();
583583
void setupStatsReporter();
584584
void setupDiagnosticVerifierIfNeeded();
585+
void setupDependencyTrackerIfNeeded();
585586
Optional<unsigned> setUpCodeCompletionBuffer();
586587

587588
/// Set up all state in the CompilerInstance to process the given input file.

lib/Frontend/Frontend.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,25 @@ void CompilerInstance::setupDiagnosticVerifierIfNeeded() {
288288
}
289289
}
290290

291+
void CompilerInstance::setupDependencyTrackerIfNeeded() {
292+
const auto &Invocation = getInvocation();
293+
const auto &opts = Invocation.getFrontendOptions();
294+
295+
if (opts.InputsAndOutputs.hasDependencyTrackerPath() ||
296+
!opts.IndexStorePath.empty() || opts.TrackSystemDeps) {
297+
// Note that we're tracking dependencies even when we don't need to write
298+
// them directly; in particular, -track-system-dependencies affects how
299+
// module interfaces get loaded, and so we need to be consistently tracking
300+
// system dependencies throughout the compiler.
301+
createDependencyTracker(opts.TrackSystemDeps);
302+
}
303+
}
304+
291305
bool CompilerInstance::setup(const CompilerInvocation &Invok) {
292306
Invocation = Invok;
293307

308+
setupDependencyTrackerIfNeeded();
309+
294310
// If initializing the overlay file system fails there's no sense in
295311
// continuing because the compiler will read the wrong files.
296312
if (setUpVirtualFileSystemOverlays())

lib/FrontendTool/FrontendTool.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2202,18 +2202,6 @@ int swift::performFrontend(ArrayRef<const char *> Args,
22022202
const DiagnosticOptions &diagOpts = Invocation.getDiagnosticOptions();
22032203
bool verifierEnabled = diagOpts.VerifyMode != DiagnosticOptions::NoVerify;
22042204

2205-
if (Invocation.getFrontendOptions()
2206-
.InputsAndOutputs.hasDependencyTrackerPath() ||
2207-
!Invocation.getFrontendOptions().IndexStorePath.empty() ||
2208-
Invocation.getFrontendOptions().TrackSystemDeps) {
2209-
// Note that we're tracking dependencies even when we don't need to write
2210-
// them directly; in particular, -track-system-dependencies affects how
2211-
// module interfaces get loaded, and so we need to be consistently tracking
2212-
// system dependencies throughout the compiler.
2213-
Instance->createDependencyTracker(
2214-
Invocation.getFrontendOptions().TrackSystemDeps);
2215-
}
2216-
22172205
if (Instance->setup(Invocation)) {
22182206
return finishDiagProcessing(1, /*verifierEnabled*/ false);
22192207
}

0 commit comments

Comments
 (0)