@@ -393,10 +393,10 @@ ModuleDepCollector::getInvocationAdjustedForModuleBuildWithoutOutputs(
393
393
}
394
394
395
395
llvm::DenseSet<const FileEntry *> ModuleDepCollector::collectModuleMapFiles (
396
- ArrayRef<ModuleDeps::DepInfo > ClangModuleDeps) const {
396
+ ArrayRef<ModuleID > ClangModuleDeps) const {
397
397
llvm::DenseSet<const FileEntry *> ModuleMapFiles;
398
- for (const auto &Info : ClangModuleDeps) {
399
- ModuleDeps *MD = ModuleDepsByID.lookup (Info. ID );
398
+ for (const ModuleID &MID : ClangModuleDeps) {
399
+ ModuleDeps *MD = ModuleDepsByID.lookup (MID );
400
400
assert (MD && " Inconsistent dependency info" );
401
401
// TODO: Track ClangModuleMapFile as `FileEntryRef`.
402
402
auto FE = ScanInstance.getFileManager ().getFile (MD->ClangModuleMapFile );
@@ -407,23 +407,21 @@ llvm::DenseSet<const FileEntry *> ModuleDepCollector::collectModuleMapFiles(
407
407
}
408
408
409
409
void ModuleDepCollector::addModuleMapFiles (
410
- CompilerInvocation &CI,
411
- ArrayRef<ModuleDeps::DepInfo> ClangModuleDeps) const {
410
+ CompilerInvocation &CI, ArrayRef<ModuleID> ClangModuleDeps) const {
412
411
if (Service.shouldEagerLoadModules ())
413
412
return ; // Only pcm is needed for eager load.
414
413
415
- for (const auto &Info : ClangModuleDeps) {
416
- ModuleDeps *MD = ModuleDepsByID.lookup (Info. ID );
414
+ for (const ModuleID &MID : ClangModuleDeps) {
415
+ ModuleDeps *MD = ModuleDepsByID.lookup (MID );
417
416
assert (MD && " Inconsistent dependency info" );
418
417
CI.getFrontendOpts ().ModuleMapFiles .push_back (MD->ClangModuleMapFile );
419
418
}
420
419
}
421
420
422
421
void ModuleDepCollector::addModuleFiles (
423
- CompilerInvocation &CI,
424
- ArrayRef<ModuleDeps::DepInfo> ClangModuleDeps) const {
425
- for (const auto &Info : ClangModuleDeps) {
426
- ModuleDeps *MD = ModuleDepsByID.lookup (Info.ID );
422
+ CompilerInvocation &CI, ArrayRef<ModuleID> ClangModuleDeps) const {
423
+ for (const ModuleID &MID : ClangModuleDeps) {
424
+ ModuleDeps *MD = ModuleDepsByID.lookup (MID);
427
425
std::string PCMPath =
428
426
Controller.lookupModuleOutput (*MD, ModuleOutputKind::ModuleFile);
429
427
@@ -436,15 +434,14 @@ void ModuleDepCollector::addModuleFiles(
436
434
CI.getFrontendOpts ().ModuleFiles .push_back (std::move (PCMPath));
437
435
else
438
436
CI.getHeaderSearchOpts ().PrebuiltModuleFiles .insert (
439
- {Info. ID .ModuleName , std::move (PCMPath)});
437
+ {MID .ModuleName , std::move (PCMPath)});
440
438
}
441
439
}
442
440
443
441
void ModuleDepCollector::addModuleFiles (
444
- CowCompilerInvocation &CI,
445
- ArrayRef<ModuleDeps::DepInfo> ClangModuleDeps) const {
446
- for (const auto &Info : ClangModuleDeps) {
447
- ModuleDeps *MD = ModuleDepsByID.lookup (Info.ID );
442
+ CowCompilerInvocation &CI, ArrayRef<ModuleID> ClangModuleDeps) const {
443
+ for (const ModuleID &MID : ClangModuleDeps) {
444
+ ModuleDeps *MD = ModuleDepsByID.lookup (MID);
448
445
std::string PCMPath =
449
446
Controller.lookupModuleOutput (*MD, ModuleOutputKind::ModuleFile);
450
447
@@ -457,7 +454,7 @@ void ModuleDepCollector::addModuleFiles(
457
454
CI.getMutFrontendOpts ().ModuleFiles .push_back (std::move (PCMPath));
458
455
else
459
456
CI.getMutHeaderSearchOpts ().PrebuiltModuleFiles .insert (
460
- {Info. ID .ModuleName , std::move (PCMPath)});
457
+ {MID .ModuleName , std::move (PCMPath)});
461
458
}
462
459
}
463
460
@@ -487,10 +484,10 @@ void ModuleDepCollector::applyDiscoveredDependencies(CompilerInvocation &CI) {
487
484
CI.getFrontendOpts ().ModuleMapFiles .emplace_back (
488
485
CurrentModuleMap->getNameAsRequested ());
489
486
490
- SmallVector<ModuleDeps::DepInfo > DirectDeps;
487
+ SmallVector<ModuleID > DirectDeps;
491
488
for (const auto &KV : ModularDeps)
492
489
if (DirectModularDeps.contains (KV.first ))
493
- DirectDeps.push_back ({ KV.second ->ID , /* Exported = */ false } );
490
+ DirectDeps.push_back (KV.second ->ID );
494
491
495
492
// TODO: Report module maps the same way it's done for modular dependencies.
496
493
addModuleMapFiles (CI, DirectDeps);
@@ -639,9 +636,9 @@ static std::string getModuleContextHash(const ModuleDeps &MD,
639
636
// example, case-insensitive paths to modulemap files. Usually such a case
640
637
// would indicate a missed optimization to canonicalize, but it may be
641
638
// difficult to canonicalize all cases when there is a VFS.
642
- for (const auto &Info : MD.ClangModuleDeps ) {
643
- HashBuilder.add (Info. ID .ModuleName );
644
- HashBuilder.add (Info. ID .ContextHash );
639
+ for (const auto &ID : MD.ClangModuleDeps ) {
640
+ HashBuilder.add (ID.ModuleName );
641
+ HashBuilder.add (ID.ContextHash );
645
642
}
646
643
647
644
HashBuilder.add (EagerLoadModules);
@@ -1021,30 +1018,22 @@ void ModuleDepCollectorPP::addAllSubmoduleDeps(
1021
1018
});
1022
1019
}
1023
1020
1024
- void ModuleDepCollectorPP::addOneModuleDep (const Module *M, bool Exported,
1025
- const ModuleID ID, ModuleDeps &MD) {
1026
- MD.ClangModuleDeps .push_back ({ID, Exported});
1027
-
1021
+ void ModuleDepCollectorPP::addOneModuleDep (const Module *M, const ModuleID ID,
1022
+ ModuleDeps &MD) {
1023
+ MD.ClangModuleDeps .push_back (ID);
1028
1024
if (MD.IsInStableDirectories )
1029
1025
MD.IsInStableDirectories = MDC.ModularDeps [M]->IsInStableDirectories ;
1030
1026
}
1031
1027
1032
1028
void ModuleDepCollectorPP::addModuleDep (
1033
1029
const Module *M, ModuleDeps &MD,
1034
1030
llvm::DenseSet<const Module *> &AddedModules) {
1035
- SmallVector<Module *> ExportedModulesVector;
1036
- M->getExportedModules (ExportedModulesVector);
1037
- llvm::DenseSet<const Module *> ExportedModulesSet (
1038
- ExportedModulesVector.begin (), ExportedModulesVector.end ());
1039
1031
for (const Module *Import : M->Imports ) {
1040
- const Module *ImportedTopLevelModule = Import->getTopLevelModule ();
1041
- if (ImportedTopLevelModule != M->getTopLevelModule () &&
1032
+ if (Import->getTopLevelModule () != M->getTopLevelModule () &&
1042
1033
!MDC.isPrebuiltModule (Import)) {
1043
- if (auto ImportID = handleTopLevelModule (ImportedTopLevelModule))
1044
- if (AddedModules.insert (ImportedTopLevelModule).second ) {
1045
- bool Exported = ExportedModulesSet.contains (ImportedTopLevelModule);
1046
- addOneModuleDep (ImportedTopLevelModule, Exported, *ImportID, MD);
1047
- }
1034
+ if (auto ImportID = handleTopLevelModule (Import->getTopLevelModule ()))
1035
+ if (AddedModules.insert (Import->getTopLevelModule ()).second )
1036
+ addOneModuleDep (Import->getTopLevelModule (), *ImportID, MD);
1048
1037
}
1049
1038
}
1050
1039
}
@@ -1068,7 +1057,7 @@ void ModuleDepCollectorPP::addAffectingClangModule(
1068
1057
!MDC.isPrebuiltModule (Affecting)) {
1069
1058
if (auto ImportID = handleTopLevelModule (Affecting))
1070
1059
if (AddedModules.insert (Affecting).second )
1071
- addOneModuleDep (Affecting, /* Exported = */ false , *ImportID, MD);
1060
+ addOneModuleDep (Affecting, *ImportID, MD);
1072
1061
}
1073
1062
}
1074
1063
}
0 commit comments