@@ -389,10 +389,10 @@ ModuleDepCollector::getInvocationAdjustedForModuleBuildWithoutOutputs(
389389}
390390
391391llvm::DenseSet<const FileEntry *> ModuleDepCollector::collectModuleMapFiles (
392- ArrayRef<ModuleDeps::DepInfo > ClangModuleDeps) const {
392+ ArrayRef<ModuleID > ClangModuleDeps) const {
393393 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 );
396396 assert (MD && " Inconsistent dependency info" );
397397 // TODO: Track ClangModuleMapFile as `FileEntryRef`.
398398 auto FE = ScanInstance.getFileManager ().getOptionalFileRef (
@@ -404,47 +404,44 @@ llvm::DenseSet<const FileEntry *> ModuleDepCollector::collectModuleMapFiles(
404404}
405405
406406void ModuleDepCollector::addModuleMapFiles (
407- CompilerInvocation &CI,
408- ArrayRef<ModuleDeps::DepInfo> ClangModuleDeps) const {
407+ CompilerInvocation &CI, ArrayRef<ModuleID> ClangModuleDeps) const {
409408 if (Service.shouldEagerLoadModules ())
410409 return ; // Only pcm is needed for eager load.
411410
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 );
414413 assert (MD && " Inconsistent dependency info" );
415414 CI.getFrontendOpts ().ModuleMapFiles .push_back (MD->ClangModuleMapFile );
416415 }
417416}
418417
419418void 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);
424422 std::string PCMPath =
425423 Controller.lookupModuleOutput (*MD, ModuleOutputKind::ModuleFile);
426424
427425 if (Service.shouldEagerLoadModules ())
428426 CI.getFrontendOpts ().ModuleFiles .push_back (std::move (PCMPath));
429427 else
430428 CI.getHeaderSearchOpts ().PrebuiltModuleFiles .insert (
431- {Info. ID .ModuleName , std::move (PCMPath)});
429+ {MID .ModuleName , std::move (PCMPath)});
432430 }
433431}
434432
435433void 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);
440437 std::string PCMPath =
441438 Controller.lookupModuleOutput (*MD, ModuleOutputKind::ModuleFile);
442439
443440 if (Service.shouldEagerLoadModules ())
444441 CI.getMutFrontendOpts ().ModuleFiles .push_back (std::move (PCMPath));
445442 else
446443 CI.getMutHeaderSearchOpts ().PrebuiltModuleFiles .insert (
447- {Info. ID .ModuleName , std::move (PCMPath)});
444+ {MID .ModuleName , std::move (PCMPath)});
448445 }
449446}
450447
@@ -474,10 +471,10 @@ void ModuleDepCollector::applyDiscoveredDependencies(CompilerInvocation &CI) {
474471 CI.getFrontendOpts ().ModuleMapFiles .emplace_back (
475472 CurrentModuleMap->getNameAsRequested ());
476473
477- SmallVector<ModuleDeps::DepInfo > DirectDeps;
474+ SmallVector<ModuleID > DirectDeps;
478475 for (const auto &KV : ModularDeps)
479476 if (DirectModularDeps.contains (KV.first ))
480- DirectDeps.push_back ({ KV.second ->ID , /* Exported = */ false } );
477+ DirectDeps.push_back (KV.second ->ID );
481478
482479 // TODO: Report module maps the same way it's done for modular dependencies.
483480 addModuleMapFiles (CI, DirectDeps);
@@ -600,9 +597,9 @@ static std::string getModuleContextHash(const ModuleDeps &MD,
600597 // example, case-insensitive paths to modulemap files. Usually such a case
601598 // would indicate a missed optimization to canonicalize, but it may be
602599 // 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 );
606603 }
607604
608605 HashBuilder.add (EagerLoadModules);
@@ -926,30 +923,22 @@ void ModuleDepCollectorPP::addAllSubmoduleDeps(
926923 });
927924}
928925
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);
933929 if (MD.IsInStableDirectories )
934930 MD.IsInStableDirectories = MDC.ModularDeps [M]->IsInStableDirectories ;
935931}
936932
937933void ModuleDepCollectorPP::addModuleDep (
938934 const Module *M, ModuleDeps &MD,
939935 llvm::DenseSet<const Module *> &AddedModules) {
940- SmallVector<Module *> ExportedModulesVector;
941- M->getExportedModules (ExportedModulesVector);
942- llvm::DenseSet<const Module *> ExportedModulesSet (
943- ExportedModulesVector.begin (), ExportedModulesVector.end ());
944936 for (const Module *Import : M->Imports ) {
945- const Module *ImportedTopLevelModule = Import->getTopLevelModule ();
946- if (ImportedTopLevelModule != M->getTopLevelModule () &&
937+ if (Import->getTopLevelModule () != M->getTopLevelModule () &&
947938 !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);
953942 }
954943 }
955944}
@@ -973,7 +962,7 @@ void ModuleDepCollectorPP::addAffectingClangModule(
973962 !MDC.isPrebuiltModule (Affecting)) {
974963 if (auto ImportID = handleTopLevelModule (Affecting))
975964 if (AddedModules.insert (Affecting).second )
976- addOneModuleDep (Affecting, /* Exported = */ false , *ImportID, MD);
965+ addOneModuleDep (Affecting, *ImportID, MD);
977966 }
978967 }
979968}
0 commit comments