@@ -308,6 +308,16 @@ void CompilerInstance::recordPrimaryInputBuffer(unsigned BufID) {
308
308
PrimaryBufferIDs.insert (BufID);
309
309
}
310
310
311
+ static bool shouldEnableRequestReferenceTracking (const CompilerInstance &CI) {
312
+ // Enable request reference dependency tracking when we're either writing
313
+ // dependencies for incremental mode, verifying dependencies, or collecting
314
+ // stats.
315
+ auto &opts = CI.getInvocation ().getFrontendOptions ();
316
+ return opts.InputsAndOutputs .hasReferenceDependenciesFilePath () ||
317
+ opts.EnableIncrementalDependencyVerifier ||
318
+ !opts.StatsOutputDir .empty ();
319
+ }
320
+
311
321
bool CompilerInstance::setUpASTContextIfNeeded () {
312
322
if (FrontendOptions::doesActionBuildModuleFromInterface (
313
323
Invocation.getFrontendOptions ().RequestedAction ) &&
@@ -318,10 +328,8 @@ bool CompilerInstance::setUpASTContextIfNeeded() {
318
328
return false ;
319
329
}
320
330
321
- // For the time being, we only need to record dependencies in batch mode
322
- // and single file builds.
323
- Invocation.getLangOptions ().RecordRequestReferences
324
- = !isWholeModuleCompilation ();
331
+ Invocation.getLangOptions ().RecordRequestReferences =
332
+ shouldEnableRequestReferenceTracking (*this );
325
333
326
334
Context.reset (ASTContext::get (
327
335
Invocation.getLangOptions (), Invocation.getTypeCheckerOptions (),
0 commit comments