@@ -295,7 +295,8 @@ ModuleDepCollector::getInvocationAdjustedForModuleBuildWithoutOutputs(
295
295
// TODO: Verify this works fine when modulemap for module A is eagerly
296
296
// loaded from A.pcm, and module map passed on the command line contains
297
297
// definition of a submodule: "explicit module A.Private { ... }".
298
- if (EagerLoadModules && DepModuleMapFiles.contains (*ModuleMapEntry))
298
+ if (Service.shouldEagerLoadModules () &&
299
+ DepModuleMapFiles.contains (*ModuleMapEntry))
299
300
continue ;
300
301
301
302
// Don't report module map file of the current module unless it also
@@ -345,7 +346,7 @@ llvm::DenseSet<const FileEntry *> ModuleDepCollector::collectModuleMapFiles(
345
346
346
347
void ModuleDepCollector::addModuleMapFiles (
347
348
CompilerInvocation &CI, ArrayRef<ModuleID> ClangModuleDeps) const {
348
- if (EagerLoadModules )
349
+ if (Service. shouldEagerLoadModules () )
349
350
return ; // Only pcm is needed for eager load.
350
351
351
352
for (const ModuleID &MID : ClangModuleDeps) {
@@ -360,7 +361,7 @@ void ModuleDepCollector::addModuleFiles(
360
361
for (const ModuleID &MID : ClangModuleDeps) {
361
362
std::string PCMPath =
362
363
Controller.lookupModuleOutput (MID, ModuleOutputKind::ModuleFile);
363
- if (EagerLoadModules )
364
+ if (Service. shouldEagerLoadModules () )
364
365
CI.getFrontendOpts ().ModuleFiles .push_back (std::move (PCMPath));
365
366
else
366
367
CI.getHeaderSearchOpts ().PrebuiltModuleFiles .insert (
@@ -373,7 +374,7 @@ void ModuleDepCollector::addModuleFiles(
373
374
for (const ModuleID &MID : ClangModuleDeps) {
374
375
std::string PCMPath =
375
376
Controller.lookupModuleOutput (MID, ModuleOutputKind::ModuleFile);
376
- if (EagerLoadModules )
377
+ if (Service. shouldEagerLoadModules () )
377
378
CI.getMutFrontendOpts ().ModuleFiles .push_back (std::move (PCMPath));
378
379
else
379
380
CI.getMutHeaderSearchOpts ().PrebuiltModuleFiles .insert (
@@ -551,8 +552,8 @@ static std::string getModuleContextHash(const ModuleDeps &MD,
551
552
void ModuleDepCollector::associateWithContextHash (
552
553
const CowCompilerInvocation &CI, bool IgnoreCWD, ModuleDeps &Deps) {
553
554
Deps.ID .ContextHash =
554
- getModuleContextHash (Deps, CI, EagerLoadModules, IgnoreCWD ,
555
- ScanInstance.getVirtualFileSystem ());
555
+ getModuleContextHash (Deps, CI, Service. shouldEagerLoadModules () ,
556
+ IgnoreCWD, ScanInstance.getVirtualFileSystem ());
556
557
bool Inserted = ModuleDepsByID.insert ({Deps.ID , &Deps}).second ;
557
558
(void )Inserted;
558
559
assert (Inserted && " duplicate module mapping" );
@@ -656,7 +657,7 @@ void ModuleDepCollectorPP::EndOfMainFile() {
656
657
657
658
MDC.Consumer .handleDependencyOutputOpts (*MDC.Opts );
658
659
659
- if (MDC.IsStdModuleP1689Format )
660
+ if (MDC.Service . getFormat () == ScanningOutputFormat::P1689 )
660
661
MDC.Consumer .handleProvidedAndRequiredStdCXXModules (
661
662
MDC.ProvidedStdCXXModule , MDC.RequiredStdCXXModules );
662
663
@@ -753,21 +754,23 @@ ModuleDepCollectorPP::handleTopLevelModule(const Module *M) {
753
754
CowCompilerInvocation CI =
754
755
MDC.getInvocationAdjustedForModuleBuildWithoutOutputs (
755
756
MD, [&](CowCompilerInvocation &BuildInvocation) {
756
- if (any (MDC.OptimizeArgs & (ScanningOptimizations::HeaderSearch |
757
- ScanningOptimizations::VFS)))
757
+ if (any (MDC.Service .getOptimizeArgs () &
758
+ (ScanningOptimizations::HeaderSearch |
759
+ ScanningOptimizations::VFS)))
758
760
optimizeHeaderSearchOpts (BuildInvocation.getMutHeaderSearchOpts (),
759
761
*MDC.ScanInstance .getASTReader (), *MF,
760
762
MDC.PrebuiltModuleVFSMap ,
761
- MDC.OptimizeArgs );
763
+ MDC.Service . getOptimizeArgs () );
762
764
763
- if (any (MDC.OptimizeArgs & ScanningOptimizations::SystemWarnings))
765
+ if (any (MDC.Service .getOptimizeArgs () &
766
+ ScanningOptimizations::SystemWarnings))
764
767
optimizeDiagnosticOpts (
765
768
BuildInvocation.getMutDiagnosticOpts (),
766
769
BuildInvocation.getFrontendOpts ().IsSystemModule );
767
770
768
- IgnoreCWD =
769
- any (MDC. OptimizeArgs & ScanningOptimizations::IgnoreCWD) &&
770
- isSafeToIgnoreCWD (BuildInvocation);
771
+ IgnoreCWD = any (MDC. Service . getOptimizeArgs () &
772
+ ScanningOptimizations::IgnoreCWD) &&
773
+ isSafeToIgnoreCWD (BuildInvocation);
771
774
if (IgnoreCWD) {
772
775
llvm::ErrorOr<std::string> CWD =
773
776
MDC.ScanInstance .getVirtualFileSystem ()
@@ -870,19 +873,17 @@ void ModuleDepCollectorPP::addAffectingClangModule(
870
873
}
871
874
872
875
ModuleDepCollector::ModuleDepCollector (
876
+ DependencyScanningService &Service,
873
877
std::unique_ptr<DependencyOutputOptions> Opts,
874
878
CompilerInstance &ScanInstance, DependencyConsumer &C,
875
879
DependencyActionController &Controller, CompilerInvocation OriginalCI,
876
- PrebuiltModuleVFSMapT PrebuiltModuleVFSMap,
877
- ScanningOptimizations OptimizeArgs, bool EagerLoadModules,
878
- bool IsStdModuleP1689Format)
879
- : ScanInstance(ScanInstance), Consumer(C), Controller(Controller),
880
+ PrebuiltModuleVFSMapT PrebuiltModuleVFSMap)
881
+ : Service(Service), ScanInstance(ScanInstance), Consumer(C),
882
+ Controller(Controller),
880
883
PrebuiltModuleVFSMap(std::move(PrebuiltModuleVFSMap)),
881
884
Opts(std::move(Opts)),
882
885
CommonInvocation(
883
- makeCommonInvocationForModuleBuild (std::move(OriginalCI))),
884
- OptimizeArgs(OptimizeArgs), EagerLoadModules(EagerLoadModules),
885
- IsStdModuleP1689Format(IsStdModuleP1689Format) {}
886
+ makeCommonInvocationForModuleBuild (std::move(OriginalCI))) {}
886
887
887
888
void ModuleDepCollector::attachToPreprocessor (Preprocessor &PP) {
888
889
PP.addPPCallbacks (std::make_unique<ModuleDepCollectorPP>(*this ));
@@ -914,7 +915,7 @@ static StringRef makeAbsoluteAndPreferred(CompilerInstance &CI, StringRef Path,
914
915
}
915
916
916
917
void ModuleDepCollector::addFileDep (StringRef Path) {
917
- if (IsStdModuleP1689Format ) {
918
+ if (Service. getFormat () == ScanningOutputFormat::P1689 ) {
918
919
// Within P1689 format, we don't want all the paths to be absolute path
919
920
// since it may violate the traditional make style dependencies info.
920
921
FileDeps.emplace_back (Path);
0 commit comments