@@ -394,30 +394,22 @@ class WrapScanModuleBuildAction : public WrapperFrontendAction {
394
394
class DependencyScanningAction : public tooling ::ToolAction {
395
395
public:
396
396
DependencyScanningAction (
397
- StringRef WorkingDirectory, DependencyConsumer &Consumer ,
398
- DependencyActionController &Controller,
397
+ DependencyScanningService &Service, StringRef WorkingDirectory ,
398
+ DependencyConsumer &Consumer, DependencyActionController &Controller,
399
399
llvm::IntrusiveRefCntPtr<DependencyScanningWorkerFilesystem> DepFS,
400
400
llvm::IntrusiveRefCntPtr<DependencyScanningCASFilesystem> DepCASFS,
401
401
llvm::IntrusiveRefCntPtr<llvm::cas::CachingOnDiskFileSystem> CacheFS,
402
- ScanningOutputFormat Format, ScanningOptimizations OptimizeArgs,
403
- bool EagerLoadModules, bool DisableFree, bool EmitDependencyFile,
402
+ bool DisableFree, bool EmitDependencyFile,
404
403
bool DiagGenerationAsCompilation, const CASOptions &CASOpts,
405
404
std::optional<StringRef> ModuleName = std::nullopt,
406
405
raw_ostream *VerboseOS = nullptr )
407
- : WorkingDirectory(WorkingDirectory), Consumer(Consumer),
406
+ : Service(Service), WorkingDirectory(WorkingDirectory), Consumer(Consumer),
408
407
Controller (Controller), DepFS(std::move(DepFS)),
409
408
DepCASFS(std::move(DepCASFS)), CacheFS(std::move(CacheFS)),
410
- Format(Format), OptimizeArgs(OptimizeArgs),
411
- EagerLoadModules(EagerLoadModules), DisableFree(DisableFree),
409
+ DisableFree(DisableFree),
412
410
CASOpts(CASOpts), EmitDependencyFile(EmitDependencyFile),
413
411
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) {}
421
413
422
414
bool runInvocation (std::shared_ptr<CompilerInvocation> Invocation,
423
415
FileManager *DriverFileMgr,
@@ -427,7 +419,7 @@ class DependencyScanningAction : public tooling::ToolAction {
427
419
CompilerInvocation OriginalInvocation (*Invocation);
428
420
// Restore the value of DisableFree, which may be modified by Tooling.
429
421
OriginalInvocation.getFrontendOpts ().DisableFree = DisableFree;
430
- if (any (OptimizeArgs & ScanningOptimizations::Macros))
422
+ if (any (Service. getOptimizeArgs () & ScanningOptimizations::Macros))
431
423
canonicalizeDefines (OriginalInvocation.getPreprocessorOpts ());
432
424
433
425
if (Scanned) {
@@ -478,7 +470,7 @@ class DependencyScanningAction : public tooling::ToolAction {
478
470
ScanInstance.getFrontendOpts ().ModulesShareFileManager = false ;
479
471
ScanInstance.getHeaderSearchOpts ().ModuleFormat = " raw" ;
480
472
ScanInstance.getHeaderSearchOpts ().ModulesIncludeVFSUsage =
481
- any (OptimizeArgs & ScanningOptimizations::VFS);
473
+ any (Service. getOptimizeArgs () & ScanningOptimizations::VFS);
482
474
483
475
// Support for virtual file system overlays.
484
476
auto FS = createVFSFromCompilerInvocation (
@@ -535,7 +527,7 @@ class DependencyScanningAction : public tooling::ToolAction {
535
527
Opts->Targets = {
536
528
deduceDepTarget (ScanInstance.getFrontendOpts ().OutputFile ,
537
529
ScanInstance.getFrontendOpts ().Inputs )};
538
- if (Format == ScanningOutputFormat::Make) {
530
+ if (Service. getFormat () == ScanningOutputFormat::Make) {
539
531
// Only 'Make' scanning needs to force this because that mode depends on
540
532
// getting the dependencies directly from \p DependencyFileGenerator.
541
533
Opts->IncludeSystemHeaders = true ;
@@ -555,7 +547,7 @@ class DependencyScanningAction : public tooling::ToolAction {
555
547
// \p DependencyScanningAction, and have the callers pass in a
556
548
// “DependencyCollector factory” so the connection of collector<->consumer
557
549
// is explicit in each \p DependencyScanningTool function.
558
- switch (Format ) {
550
+ switch (Service. getFormat () ) {
559
551
case ScanningOutputFormat::Make:
560
552
case ScanningOutputFormat::Tree:
561
553
ScanInstance.addDependencyCollector (
@@ -576,9 +568,8 @@ class DependencyScanningAction : public tooling::ToolAction {
576
568
}
577
569
578
570
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));
582
573
ScanInstance.addDependencyCollector (MDC);
583
574
ScanInstance.setGenModuleActionWrapper (
584
575
[&Controller = Controller](const FrontendOptions &Opts,
@@ -680,16 +671,13 @@ class DependencyScanningAction : public tooling::ToolAction {
680
671
return nullptr ;
681
672
}
682
673
683
- private:
674
+ DependencyScanningService &Service;
684
675
StringRef WorkingDirectory;
685
676
DependencyConsumer &Consumer;
686
677
DependencyActionController &Controller;
687
678
llvm::IntrusiveRefCntPtr<DependencyScanningWorkerFilesystem> DepFS;
688
679
llvm::IntrusiveRefCntPtr<DependencyScanningCASFilesystem> DepCASFS;
689
680
llvm::IntrusiveRefCntPtr<llvm::cas::CachingOnDiskFileSystem> CacheFS;
690
- ScanningOutputFormat Format;
691
- ScanningOptimizations OptimizeArgs;
692
- bool EagerLoadModules;
693
681
bool DisableFree;
694
682
const CASOptions &CASOpts;
695
683
bool EmitDependencyFile = false ;
@@ -708,8 +696,7 @@ class DependencyScanningAction : public tooling::ToolAction {
708
696
DependencyScanningWorker::DependencyScanningWorker (
709
697
DependencyScanningService &Service,
710
698
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS)
711
- : Format(Service.getFormat()), OptimizeArgs(Service.getOptimizeArgs()),
712
- EagerLoadModules(Service.shouldEagerLoadModules()),
699
+ : Service(Service),
713
700
CASOpts(Service.getCASOpts()), CAS(Service.getCAS()) {
714
701
PCHContainerOps = std::make_shared<PCHContainerOperations>();
715
702
// We need to read object files from PCH built outside the scanner.
@@ -878,9 +865,8 @@ bool DependencyScanningWorker::scanDependencies(
878
865
// in-process; preserve the original value, which is
879
866
// always true for a driver invocation.
880
867
bool DisableFree = true ;
881
- DependencyScanningAction Action (WorkingDirectory, Consumer, Controller, DepFS,
868
+ DependencyScanningAction Action (Service, WorkingDirectory, Consumer, Controller, DepFS,
882
869
DepCASFS, CacheFS,
883
- Format, OptimizeArgs, EagerLoadModules,
884
870
DisableFree,
885
871
/* EmitDependencyFile=*/ false ,
886
872
/* DiagGenerationAsCompilation=*/ false , getCASOpts (),
@@ -1033,13 +1019,12 @@ void DependencyScanningWorker::computeDependenciesFromCompilerInvocation(
1033
1019
1034
1020
// FIXME: EmitDependencyFile should only be set when it's for a real
1035
1021
// 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);
1043
1028
1044
1029
// Ignore result; we're just collecting dependencies.
1045
1030
//
0 commit comments