@@ -389,10 +389,10 @@ ModuleDepCollector::getInvocationAdjustedForModuleBuildWithoutOutputs(
389
389
}
390
390
391
391
llvm::DenseSet<const FileEntry *> ModuleDepCollector::collectModuleMapFiles (
392
- ArrayRef<ModuleDeps::DepInfo > ClangModuleDeps) const {
392
+ ArrayRef<ModuleID > ClangModuleDeps) const {
393
393
llvm::DenseSet<const FileEntry *> ModuleMapFiles;
394
- for (const auto &Info : ClangModuleDeps) {
395
- ModuleDeps *MD = ModuleDepsByID.lookup (Info. ID );
394
+ for (const ModuleID &MID : ClangModuleDeps) {
395
+ ModuleDeps *MD = ModuleDepsByID.lookup (MID );
396
396
assert (MD && " Inconsistent dependency info" );
397
397
// TODO: Track ClangModuleMapFile as `FileEntryRef`.
398
398
auto FE = ScanInstance.getFileManager ().getOptionalFileRef (
@@ -404,47 +404,44 @@ llvm::DenseSet<const FileEntry *> ModuleDepCollector::collectModuleMapFiles(
404
404
}
405
405
406
406
void ModuleDepCollector::addModuleMapFiles (
407
- CompilerInvocation &CI,
408
- ArrayRef<ModuleDeps::DepInfo> ClangModuleDeps) const {
407
+ CompilerInvocation &CI, ArrayRef<ModuleID> ClangModuleDeps) const {
409
408
if (Service.shouldEagerLoadModules ())
410
409
return ; // Only pcm is needed for eager load.
411
410
412
- for (const auto &Info : ClangModuleDeps) {
413
- ModuleDeps *MD = ModuleDepsByID.lookup (Info. ID );
411
+ for (const ModuleID &MID : ClangModuleDeps) {
412
+ ModuleDeps *MD = ModuleDepsByID.lookup (MID );
414
413
assert (MD && " Inconsistent dependency info" );
415
414
CI.getFrontendOpts ().ModuleMapFiles .push_back (MD->ClangModuleMapFile );
416
415
}
417
416
}
418
417
419
418
void ModuleDepCollector::addModuleFiles (
420
- CompilerInvocation &CI,
421
- ArrayRef<ModuleDeps::DepInfo> ClangModuleDeps) const {
422
- for (const auto &Info : ClangModuleDeps) {
423
- ModuleDeps *MD = ModuleDepsByID.lookup (Info.ID );
419
+ CompilerInvocation &CI, ArrayRef<ModuleID> ClangModuleDeps) const {
420
+ for (const ModuleID &MID : ClangModuleDeps) {
421
+ ModuleDeps *MD = ModuleDepsByID.lookup (MID);
424
422
std::string PCMPath =
425
423
Controller.lookupModuleOutput (*MD, ModuleOutputKind::ModuleFile);
426
424
427
425
if (Service.shouldEagerLoadModules ())
428
426
CI.getFrontendOpts ().ModuleFiles .push_back (std::move (PCMPath));
429
427
else
430
428
CI.getHeaderSearchOpts ().PrebuiltModuleFiles .insert (
431
- {Info. ID .ModuleName , std::move (PCMPath)});
429
+ {MID .ModuleName , std::move (PCMPath)});
432
430
}
433
431
}
434
432
435
433
void ModuleDepCollector::addModuleFiles (
436
- CowCompilerInvocation &CI,
437
- ArrayRef<ModuleDeps::DepInfo> ClangModuleDeps) const {
438
- for (const auto &Info : ClangModuleDeps) {
439
- ModuleDeps *MD = ModuleDepsByID.lookup (Info.ID );
434
+ CowCompilerInvocation &CI, ArrayRef<ModuleID> ClangModuleDeps) const {
435
+ for (const ModuleID &MID : ClangModuleDeps) {
436
+ ModuleDeps *MD = ModuleDepsByID.lookup (MID);
440
437
std::string PCMPath =
441
438
Controller.lookupModuleOutput (*MD, ModuleOutputKind::ModuleFile);
442
439
443
440
if (Service.shouldEagerLoadModules ())
444
441
CI.getMutFrontendOpts ().ModuleFiles .push_back (std::move (PCMPath));
445
442
else
446
443
CI.getMutHeaderSearchOpts ().PrebuiltModuleFiles .insert (
447
- {Info. ID .ModuleName , std::move (PCMPath)});
444
+ {MID .ModuleName , std::move (PCMPath)});
448
445
}
449
446
}
450
447
@@ -474,10 +471,10 @@ void ModuleDepCollector::applyDiscoveredDependencies(CompilerInvocation &CI) {
474
471
CI.getFrontendOpts ().ModuleMapFiles .emplace_back (
475
472
CurrentModuleMap->getNameAsRequested ());
476
473
477
- SmallVector<ModuleDeps::DepInfo > DirectDeps;
474
+ SmallVector<ModuleID > DirectDeps;
478
475
for (const auto &KV : ModularDeps)
479
476
if (DirectModularDeps.contains (KV.first ))
480
- DirectDeps.push_back ({ KV.second ->ID , /* Exported = */ false } );
477
+ DirectDeps.push_back (KV.second ->ID );
481
478
482
479
// TODO: Report module maps the same way it's done for modular dependencies.
483
480
addModuleMapFiles (CI, DirectDeps);
@@ -600,9 +597,9 @@ static std::string getModuleContextHash(const ModuleDeps &MD,
600
597
// example, case-insensitive paths to modulemap files. Usually such a case
601
598
// would indicate a missed optimization to canonicalize, but it may be
602
599
// difficult to canonicalize all cases when there is a VFS.
603
- for (const auto &Info : MD.ClangModuleDeps ) {
604
- HashBuilder.add (Info. ID .ModuleName );
605
- HashBuilder.add (Info. ID .ContextHash );
600
+ for (const auto &ID : MD.ClangModuleDeps ) {
601
+ HashBuilder.add (ID.ModuleName );
602
+ HashBuilder.add (ID.ContextHash );
606
603
}
607
604
608
605
HashBuilder.add (EagerLoadModules);
@@ -926,30 +923,22 @@ void ModuleDepCollectorPP::addAllSubmoduleDeps(
926
923
});
927
924
}
928
925
929
- void ModuleDepCollectorPP::addOneModuleDep (const Module *M, bool Exported,
930
- const ModuleID ID, ModuleDeps &MD) {
931
- MD.ClangModuleDeps .push_back ({ID, Exported});
932
-
926
+ void ModuleDepCollectorPP::addOneModuleDep (const Module *M, const ModuleID ID,
927
+ ModuleDeps &MD) {
928
+ MD.ClangModuleDeps .push_back (ID);
933
929
if (MD.IsInStableDirectories )
934
930
MD.IsInStableDirectories = MDC.ModularDeps [M]->IsInStableDirectories ;
935
931
}
936
932
937
933
void ModuleDepCollectorPP::addModuleDep (
938
934
const Module *M, ModuleDeps &MD,
939
935
llvm::DenseSet<const Module *> &AddedModules) {
940
- SmallVector<Module *> ExportedModulesVector;
941
- M->getExportedModules (ExportedModulesVector);
942
- llvm::DenseSet<const Module *> ExportedModulesSet (
943
- ExportedModulesVector.begin (), ExportedModulesVector.end ());
944
936
for (const Module *Import : M->Imports ) {
945
- const Module *ImportedTopLevelModule = Import->getTopLevelModule ();
946
- if (ImportedTopLevelModule != M->getTopLevelModule () &&
937
+ if (Import->getTopLevelModule () != M->getTopLevelModule () &&
947
938
!MDC.isPrebuiltModule (Import)) {
948
- if (auto ImportID = handleTopLevelModule (ImportedTopLevelModule))
949
- if (AddedModules.insert (ImportedTopLevelModule).second ) {
950
- bool Exported = ExportedModulesSet.contains (ImportedTopLevelModule);
951
- addOneModuleDep (ImportedTopLevelModule, Exported, *ImportID, MD);
952
- }
939
+ if (auto ImportID = handleTopLevelModule (Import->getTopLevelModule ()))
940
+ if (AddedModules.insert (Import->getTopLevelModule ()).second )
941
+ addOneModuleDep (Import->getTopLevelModule (), *ImportID, MD);
953
942
}
954
943
}
955
944
}
@@ -973,7 +962,7 @@ void ModuleDepCollectorPP::addAffectingClangModule(
973
962
!MDC.isPrebuiltModule (Affecting)) {
974
963
if (auto ImportID = handleTopLevelModule (Affecting))
975
964
if (AddedModules.insert (Affecting).second )
976
- addOneModuleDep (Affecting, /* Exported = */ false , *ImportID, MD);
965
+ addOneModuleDep (Affecting, *ImportID, MD);
977
966
}
978
967
}
979
968
}
0 commit comments