Skip to content

Commit 5acd9d1

Browse files
authored
[clang][scan] Report module dependencies in topological order (#107474)
1 parent 144314e commit 5acd9d1

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -569,12 +569,11 @@ ModuleDepCollectorPP::handleTopLevelModule(const Module *M) {
569569
return {};
570570

571571
// If this module has been handled already, just return its ID.
572-
auto ModI = MDC.ModularDeps.insert({M, nullptr});
573-
if (!ModI.second)
574-
return ModI.first->second->ID;
572+
if (auto ModI = MDC.ModularDeps.find(M); ModI != MDC.ModularDeps.end())
573+
return ModI->second->ID;
575574

576-
ModI.first->second = std::make_unique<ModuleDeps>();
577-
ModuleDeps &MD = *ModI.first->second;
575+
auto OwnedMD = std::make_unique<ModuleDeps>();
576+
ModuleDeps &MD = *OwnedMD;
578577

579578
MD.ID.ModuleName = M->getFullModuleName();
580579
MD.IsSystem = M->IsSystem;
@@ -650,6 +649,8 @@ ModuleDepCollectorPP::handleTopLevelModule(const Module *M) {
650649

651650
MD.BuildInfo = std::move(CI);
652651

652+
MDC.ModularDeps.insert({M, std::move(OwnedMD)});
653+
653654
return MD.ID;
654655
}
655656

0 commit comments

Comments
 (0)