Skip to content

Commit

Permalink
[clang][scan] Report module dependencies in topological order (llvm#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
jansvoboda11 authored Sep 6, 2024
1 parent 144314e commit 5acd9d1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,12 +569,11 @@ ModuleDepCollectorPP::handleTopLevelModule(const Module *M) {
return {};

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

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

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

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

MDC.ModularDeps.insert({M, std::move(OwnedMD)});

return MD.ID;
}

Expand Down

0 comments on commit 5acd9d1

Please sign in to comment.