[clang] 5acd9d1 - [clang][scan] Report module dependencies in topological order (#107474)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 5 19:13:12 PDT 2024
Author: Jan Svoboda
Date: 2024-09-05T19:13:08-07:00
New Revision: 5acd9d11373ca67f0d4baf17a78ebb56193a7df0
URL: https://github.com/llvm/llvm-project/commit/5acd9d11373ca67f0d4baf17a78ebb56193a7df0
DIFF: https://github.com/llvm/llvm-project/commit/5acd9d11373ca67f0d4baf17a78ebb56193a7df0.diff
LOG: [clang][scan] Report module dependencies in topological order (#107474)
Added:
Modified:
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
Removed:
################################################################################
diff --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index 370d834846859f..c775adc0ddd73c 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -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;
@@ -650,6 +649,8 @@ ModuleDepCollectorPP::handleTopLevelModule(const Module *M) {
MD.BuildInfo = std::move(CI);
+ MDC.ModularDeps.insert({M, std::move(OwnedMD)});
+
return MD.ID;
}
More information about the cfe-commits
mailing list