@@ -400,10 +400,10 @@ ModuleDepCollector::getInvocationAdjustedForModuleBuildWithoutOutputs(
400
400
}
401
401
402
402
llvm::DenseSet<const FileEntry *> ModuleDepCollector::collectModuleMapFiles (
403
- ArrayRef<ModuleDeps::DepInfo > ClangModuleDeps) const {
403
+ ArrayRef<ModuleID > ClangModuleDeps) const {
404
404
llvm::DenseSet<const FileEntry *> ModuleMapFiles;
405
- for (const auto &Info : ClangModuleDeps) {
406
- ModuleDeps *MD = ModuleDepsByID.lookup (Info. ID );
405
+ for (const ModuleID &MID : ClangModuleDeps) {
406
+ ModuleDeps *MD = ModuleDepsByID.lookup (MID );
407
407
assert (MD && " Inconsistent dependency info" );
408
408
// TODO: Track ClangModuleMapFile as `FileEntryRef`.
409
409
auto FE = ScanInstance.getFileManager ().getFile (MD->ClangModuleMapFile );
@@ -414,23 +414,21 @@ llvm::DenseSet<const FileEntry *> ModuleDepCollector::collectModuleMapFiles(
414
414
}
415
415
416
416
void ModuleDepCollector::addModuleMapFiles (
417
- CompilerInvocation &CI,
418
- ArrayRef<ModuleDeps::DepInfo> ClangModuleDeps) const {
417
+ CompilerInvocation &CI, ArrayRef<ModuleID> ClangModuleDeps) const {
419
418
if (Service.shouldEagerLoadModules ())
420
419
return ; // Only pcm is needed for eager load.
421
420
422
- for (const auto &Info : ClangModuleDeps) {
423
- ModuleDeps *MD = ModuleDepsByID.lookup (Info. ID );
421
+ for (const ModuleID &MID : ClangModuleDeps) {
422
+ ModuleDeps *MD = ModuleDepsByID.lookup (MID );
424
423
assert (MD && " Inconsistent dependency info" );
425
424
CI.getFrontendOpts ().ModuleMapFiles .push_back (MD->ClangModuleMapFile );
426
425
}
427
426
}
428
427
429
428
void ModuleDepCollector::addModuleFiles (
430
- CompilerInvocation &CI,
431
- ArrayRef<ModuleDeps::DepInfo> ClangModuleDeps) const {
432
- for (const auto &Info : ClangModuleDeps) {
433
- ModuleDeps *MD = ModuleDepsByID.lookup (Info.ID );
429
+ CompilerInvocation &CI, ArrayRef<ModuleID> ClangModuleDeps) const {
430
+ for (const ModuleID &MID : ClangModuleDeps) {
431
+ ModuleDeps *MD = ModuleDepsByID.lookup (MID);
434
432
std::string PCMPath =
435
433
Controller.lookupModuleOutput (*MD, ModuleOutputKind::ModuleFile);
436
434
@@ -443,15 +441,14 @@ void ModuleDepCollector::addModuleFiles(
443
441
CI.getFrontendOpts ().ModuleFiles .push_back (std::move (PCMPath));
444
442
else
445
443
CI.getHeaderSearchOpts ().PrebuiltModuleFiles .insert (
446
- {Info. ID .ModuleName , std::move (PCMPath)});
444
+ {MID .ModuleName , std::move (PCMPath)});
447
445
}
448
446
}
449
447
450
448
void ModuleDepCollector::addModuleFiles (
451
- CowCompilerInvocation &CI,
452
- ArrayRef<ModuleDeps::DepInfo> ClangModuleDeps) const {
453
- for (const auto &Info : ClangModuleDeps) {
454
- ModuleDeps *MD = ModuleDepsByID.lookup (Info.ID );
449
+ CowCompilerInvocation &CI, ArrayRef<ModuleID> ClangModuleDeps) const {
450
+ for (const ModuleID &MID : ClangModuleDeps) {
451
+ ModuleDeps *MD = ModuleDepsByID.lookup (MID);
455
452
std::string PCMPath =
456
453
Controller.lookupModuleOutput (*MD, ModuleOutputKind::ModuleFile);
457
454
@@ -464,7 +461,7 @@ void ModuleDepCollector::addModuleFiles(
464
461
CI.getMutFrontendOpts ().ModuleFiles .push_back (std::move (PCMPath));
465
462
else
466
463
CI.getMutHeaderSearchOpts ().PrebuiltModuleFiles .insert (
467
- {Info. ID .ModuleName , std::move (PCMPath)});
464
+ {MID .ModuleName , std::move (PCMPath)});
468
465
}
469
466
}
470
467
@@ -494,10 +491,10 @@ void ModuleDepCollector::applyDiscoveredDependencies(CompilerInvocation &CI) {
494
491
CI.getFrontendOpts ().ModuleMapFiles .emplace_back (
495
492
CurrentModuleMap->getNameAsRequested ());
496
493
497
- SmallVector<ModuleDeps::DepInfo > DirectDeps;
494
+ SmallVector<ModuleID > DirectDeps;
498
495
for (const auto &KV : ModularDeps)
499
496
if (DirectModularDeps.contains (KV.first ))
500
- DirectDeps.push_back ({ KV.second ->ID , /* Exported = */ false } );
497
+ DirectDeps.push_back (KV.second ->ID );
501
498
502
499
// TODO: Report module maps the same way it's done for modular dependencies.
503
500
addModuleMapFiles (CI, DirectDeps);
@@ -646,9 +643,9 @@ static std::string getModuleContextHash(const ModuleDeps &MD,
646
643
// example, case-insensitive paths to modulemap files. Usually such a case
647
644
// would indicate a missed optimization to canonicalize, but it may be
648
645
// difficult to canonicalize all cases when there is a VFS.
649
- for (const auto &Info : MD.ClangModuleDeps ) {
650
- HashBuilder.add (Info. ID .ModuleName );
651
- HashBuilder.add (Info. ID .ContextHash );
646
+ for (const auto &ID : MD.ClangModuleDeps ) {
647
+ HashBuilder.add (ID.ModuleName );
648
+ HashBuilder.add (ID.ContextHash );
652
649
}
653
650
654
651
HashBuilder.add (EagerLoadModules);
@@ -1028,30 +1025,22 @@ void ModuleDepCollectorPP::addAllSubmoduleDeps(
1028
1025
});
1029
1026
}
1030
1027
1031
- void ModuleDepCollectorPP::addOneModuleDep (const Module *M, bool Exported,
1032
- const ModuleID ID, ModuleDeps &MD) {
1033
- MD.ClangModuleDeps .push_back ({ID, Exported});
1034
-
1028
+ void ModuleDepCollectorPP::addOneModuleDep (const Module *M, const ModuleID ID,
1029
+ ModuleDeps &MD) {
1030
+ MD.ClangModuleDeps .push_back (ID);
1035
1031
if (MD.IsInStableDirectories )
1036
1032
MD.IsInStableDirectories = MDC.ModularDeps [M]->IsInStableDirectories ;
1037
1033
}
1038
1034
1039
1035
void ModuleDepCollectorPP::addModuleDep (
1040
1036
const Module *M, ModuleDeps &MD,
1041
1037
llvm::DenseSet<const Module *> &AddedModules) {
1042
- SmallVector<Module *> ExportedModulesVector;
1043
- M->getExportedModules (ExportedModulesVector);
1044
- llvm::DenseSet<const Module *> ExportedModulesSet (
1045
- ExportedModulesVector.begin (), ExportedModulesVector.end ());
1046
1038
for (const Module *Import : M->Imports ) {
1047
- const Module *ImportedTopLevelModule = Import->getTopLevelModule ();
1048
- if (ImportedTopLevelModule != M->getTopLevelModule () &&
1039
+ if (Import->getTopLevelModule () != M->getTopLevelModule () &&
1049
1040
!MDC.isPrebuiltModule (Import)) {
1050
- if (auto ImportID = handleTopLevelModule (ImportedTopLevelModule))
1051
- if (AddedModules.insert (ImportedTopLevelModule).second ) {
1052
- bool Exported = ExportedModulesSet.contains (ImportedTopLevelModule);
1053
- addOneModuleDep (ImportedTopLevelModule, Exported, *ImportID, MD);
1054
- }
1041
+ if (auto ImportID = handleTopLevelModule (Import->getTopLevelModule ()))
1042
+ if (AddedModules.insert (Import->getTopLevelModule ()).second )
1043
+ addOneModuleDep (Import->getTopLevelModule (), *ImportID, MD);
1055
1044
}
1056
1045
}
1057
1046
}
@@ -1075,7 +1064,7 @@ void ModuleDepCollectorPP::addAffectingClangModule(
1075
1064
!MDC.isPrebuiltModule (Affecting)) {
1076
1065
if (auto ImportID = handleTopLevelModule (Affecting))
1077
1066
if (AddedModules.insert (Affecting).second )
1078
- addOneModuleDep (Affecting, /* Exported = */ false , *ImportID, MD);
1067
+ addOneModuleDep (Affecting, *ImportID, MD);
1079
1068
}
1080
1069
}
1081
1070
}
0 commit comments