[clang-tools-extra] [clangd] Fix prerequisite module stale dependency detection (PR #234181)

SLIMANI Lukas via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 30 10:55:56 PDT 2026


================
@@ -1235,6 +1243,39 @@ void ModulesBuilder::ModulesBuilderImpl::getPrebuiltModuleFile(
   }
 }
 
+bool ModulesBuilder::ModulesBuilderImpl::hasNewerDependency(
+    StringRef ModuleName, PathRef PublishedModuleFilePath,
+    PathRef RequiredSource, PathRef ModuleUnitFileName,
+    CachingProjectModules &MDB) {
+  std::vector<std::string> Deps = MDB.getRequiredModules(ModuleUnitFileName);
+  if (Deps.empty())
+    return false;
+
+  llvm::sys::fs::file_status Status;
+  // Without a published module file there is nothing to compare against, so
+  // treat any cached copy as stale.
+  if (llvm::sys::fs::status(PublishedModuleFilePath, Status))
+    return true;
+  const auto ModuleTime = Status.getLastModificationTime();
+
+  return llvm::any_of(Deps, [&](const std::string &Dep) {
+    std::string DepSource = MDB.getSourceForModuleName(Dep, RequiredSource);
----------------
lslimani wrote:

I haven't studied the `getSourceForModuleName()` function much so you're probably right as I said that using `requiredModule` seemed more logic to me than the other but it seemed to have the same result, and if what you say about the impl of `getSourceForModuleName()` then yes it is kinda stupid to use `requiredModule`, it was not doing what I thought.

https://github.com/llvm/llvm-project/pull/234181


More information about the cfe-commits mailing list