@@ -394,30 +394,22 @@ class WrapScanModuleBuildAction : public WrapperFrontendAction {
394394class DependencyScanningAction : public tooling ::ToolAction {
395395public:
396396 DependencyScanningAction (
397- StringRef WorkingDirectory, DependencyConsumer &Consumer ,
398- DependencyActionController &Controller,
397+ DependencyScanningService &Service, StringRef WorkingDirectory ,
398+ DependencyConsumer &Consumer, DependencyActionController &Controller,
399399 llvm::IntrusiveRefCntPtr<DependencyScanningWorkerFilesystem> DepFS,
400400 llvm::IntrusiveRefCntPtr<DependencyScanningCASFilesystem> DepCASFS,
401401 llvm::IntrusiveRefCntPtr<llvm::cas::CachingOnDiskFileSystem> CacheFS,
402- ScanningOutputFormat Format, ScanningOptimizations OptimizeArgs,
403- bool EagerLoadModules, bool DisableFree, bool EmitDependencyFile,
402+ bool DisableFree, bool EmitDependencyFile,
404403 bool DiagGenerationAsCompilation, const CASOptions &CASOpts,
405404 std::optional<StringRef> ModuleName = std::nullopt ,
406405 raw_ostream *VerboseOS = nullptr )
407- : WorkingDirectory(WorkingDirectory), Consumer(Consumer),
406+ : Service(Service), WorkingDirectory(WorkingDirectory), Consumer(Consumer),
408407 Controller (Controller), DepFS(std::move(DepFS)),
409408 DepCASFS(std::move(DepCASFS)), CacheFS(std::move(CacheFS)),
410- Format(Format), OptimizeArgs(OptimizeArgs),
411- EagerLoadModules(EagerLoadModules), DisableFree(DisableFree),
409+ DisableFree(DisableFree),
412410 CASOpts(CASOpts), EmitDependencyFile(EmitDependencyFile),
413411 DiagGenerationAsCompilation(DiagGenerationAsCompilation),
414- ModuleName(ModuleName), VerboseOS(VerboseOS) {
415- // The FullIncludeTree output format completely subsumes header search and
416- // VFS optimizations due to how it works. Disable these optimizations so
417- // we're not doing unneeded work.
418- if (Format == ScanningOutputFormat::FullIncludeTree)
419- this ->OptimizeArgs &= ~ScanningOptimizations::FullIncludeTreeIrrelevant;
420- }
412+ ModuleName(ModuleName), VerboseOS(VerboseOS) {}
421413
422414 bool runInvocation (std::shared_ptr<CompilerInvocation> Invocation,
423415 FileManager *DriverFileMgr,
@@ -427,7 +419,7 @@ class DependencyScanningAction : public tooling::ToolAction {
427419 CompilerInvocation OriginalInvocation (*Invocation);
428420 // Restore the value of DisableFree, which may be modified by Tooling.
429421 OriginalInvocation.getFrontendOpts ().DisableFree = DisableFree;
430- if (any (OptimizeArgs & ScanningOptimizations::Macros))
422+ if (any (Service. getOptimizeArgs () & ScanningOptimizations::Macros))
431423 canonicalizeDefines (OriginalInvocation.getPreprocessorOpts ());
432424
433425 if (Scanned) {
@@ -478,7 +470,7 @@ class DependencyScanningAction : public tooling::ToolAction {
478470 ScanInstance.getFrontendOpts ().ModulesShareFileManager = false ;
479471 ScanInstance.getHeaderSearchOpts ().ModuleFormat = " raw" ;
480472 ScanInstance.getHeaderSearchOpts ().ModulesIncludeVFSUsage =
481- any (OptimizeArgs & ScanningOptimizations::VFS);
473+ any (Service. getOptimizeArgs () & ScanningOptimizations::VFS);
482474
483475 // Support for virtual file system overlays.
484476 auto FS = createVFSFromCompilerInvocation (
@@ -535,7 +527,7 @@ class DependencyScanningAction : public tooling::ToolAction {
535527 Opts->Targets = {
536528 deduceDepTarget (ScanInstance.getFrontendOpts ().OutputFile ,
537529 ScanInstance.getFrontendOpts ().Inputs )};
538- if (Format == ScanningOutputFormat::Make) {
530+ if (Service. getFormat () == ScanningOutputFormat::Make) {
539531 // Only 'Make' scanning needs to force this because that mode depends on
540532 // getting the dependencies directly from \p DependencyFileGenerator.
541533 Opts->IncludeSystemHeaders = true ;
@@ -555,7 +547,7 @@ class DependencyScanningAction : public tooling::ToolAction {
555547 // \p DependencyScanningAction, and have the callers pass in a
556548 // “DependencyCollector factory” so the connection of collector<->consumer
557549 // is explicit in each \p DependencyScanningTool function.
558- switch (Format ) {
550+ switch (Service. getFormat () ) {
559551 case ScanningOutputFormat::Make:
560552 case ScanningOutputFormat::Tree:
561553 ScanInstance.addDependencyCollector (
@@ -576,9 +568,8 @@ class DependencyScanningAction : public tooling::ToolAction {
576568 }
577569
578570 MDC = std::make_shared<ModuleDepCollector>(
579- std::move (Opts), ScanInstance, Consumer, Controller,
580- OriginalInvocation, std::move (PrebuiltModuleVFSMap), OptimizeArgs,
581- EagerLoadModules, Format == ScanningOutputFormat::P1689);
571+ Service, std::move (Opts), ScanInstance, Consumer, Controller,
572+ OriginalInvocation, std::move (PrebuiltModuleVFSMap));
582573 ScanInstance.addDependencyCollector (MDC);
583574 ScanInstance.setGenModuleActionWrapper (
584575 [&Controller = Controller](const FrontendOptions &Opts,
@@ -680,16 +671,13 @@ class DependencyScanningAction : public tooling::ToolAction {
680671 return nullptr ;
681672 }
682673
683- private:
674+ DependencyScanningService &Service;
684675 StringRef WorkingDirectory;
685676 DependencyConsumer &Consumer;
686677 DependencyActionController &Controller;
687678 llvm::IntrusiveRefCntPtr<DependencyScanningWorkerFilesystem> DepFS;
688679 llvm::IntrusiveRefCntPtr<DependencyScanningCASFilesystem> DepCASFS;
689680 llvm::IntrusiveRefCntPtr<llvm::cas::CachingOnDiskFileSystem> CacheFS;
690- ScanningOutputFormat Format;
691- ScanningOptimizations OptimizeArgs;
692- bool EagerLoadModules;
693681 bool DisableFree;
694682 const CASOptions &CASOpts;
695683 bool EmitDependencyFile = false ;
@@ -708,8 +696,7 @@ class DependencyScanningAction : public tooling::ToolAction {
708696DependencyScanningWorker::DependencyScanningWorker (
709697 DependencyScanningService &Service,
710698 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS)
711- : Format(Service.getFormat()), OptimizeArgs(Service.getOptimizeArgs()),
712- EagerLoadModules(Service.shouldEagerLoadModules()),
699+ : Service(Service),
713700 CASOpts(Service.getCASOpts()), CAS(Service.getCAS()) {
714701 PCHContainerOps = std::make_shared<PCHContainerOperations>();
715702 // We need to read object files from PCH built outside the scanner.
@@ -878,9 +865,8 @@ bool DependencyScanningWorker::scanDependencies(
878865 // in-process; preserve the original value, which is
879866 // always true for a driver invocation.
880867 bool DisableFree = true ;
881- DependencyScanningAction Action (WorkingDirectory, Consumer, Controller, DepFS,
868+ DependencyScanningAction Action (Service, WorkingDirectory, Consumer, Controller, DepFS,
882869 DepCASFS, CacheFS,
883- Format, OptimizeArgs, EagerLoadModules,
884870 DisableFree,
885871 /* EmitDependencyFile=*/ false ,
886872 /* DiagGenerationAsCompilation=*/ false , getCASOpts (),
@@ -1033,13 +1019,12 @@ void DependencyScanningWorker::computeDependenciesFromCompilerInvocation(
10331019
10341020 // FIXME: EmitDependencyFile should only be set when it's for a real
10351021 // compilation.
1036- DependencyScanningAction Action (
1037- WorkingDirectory, DepsConsumer, Controller, DepFS, DepCASFS, CacheFS,
1038- Format,
1039- ScanningOptimizations::Default, /* DisableFree=*/ false , EagerLoadModules,
1040- /* EmitDependencyFile=*/ !DepFile.empty (), DiagGenerationAsCompilation,
1041- getCASOpts (),
1042- /* ModuleName=*/ std::nullopt , VerboseOS);
1022+ DependencyScanningAction Action (Service, WorkingDirectory, DepsConsumer,
1023+ Controller, DepFS, DepCASFS, CacheFS,
1024+ /* DisableFree=*/ false ,
1025+ /* EmitDependencyFile=*/ !DepFile.empty (),
1026+ DiagGenerationAsCompilation, getCASOpts (),
1027+ /* ModuleName=*/ std::nullopt , VerboseOS);
10431028
10441029 // Ignore result; we're just collecting dependencies.
10451030 //
0 commit comments