[clang-tools-extra] [clangd] [C++20] [Modules] Add scanning cache (PR #125988)
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 13 18:43:54 PST 2025
================
@@ -380,30 +381,114 @@ llvm::SmallVector<StringRef> getAllRequiredModules(ProjectModules &MDB,
return ModuleNames;
}
+class CachingProjectModules : public ProjectModules {
+public:
+ CachingProjectModules(const GlobalCompilationDatabase &CDB) : CDB(CDB) {}
+
+ std::vector<std::string> getRequiredModules(PathRef File) override {
+ std::unique_ptr<ProjectModules> MDB = CDB.getProjectModules(File);
+ if (!MDB) {
+ elog("Failed to get Project Modules information for {0}", File);
+ return {};
+ }
+ return MDB->getRequiredModules(File);
+ }
+
+ std::string getModuleNameForSource(PathRef File) override {
+ std::unique_ptr<ProjectModules> MDB = CDB.getProjectModules(File);
+ if (!MDB) {
+ elog("Failed to get Project Modules information for {0}", File);
+ return {};
+ }
+ return MDB->getModuleNameForSource(File);
+ }
+
+ void setCommandMangler(CommandMangler M) override {
+ // GlobalCompilationDatabase::getProjectModules() will set mangler
+ // for the underlying ProjectModules.
+ }
----------------
ChuanqiXu9 wrote:
Done
https://github.com/llvm/llvm-project/pull/125988
More information about the cfe-commits
mailing list