https://github.com/Li-Zheng-Rong created https://github.com/llvm/llvm-project/pull/199343
When checking for multiple source files declaring the same module, the comparison used raw string equality on file paths. This causes false positives when the same file is represented by different but equivalent path strings. Use pathEqual(normalizePath(...), normalizePath(...)) instead to compare canonical paths, consistent with how clangd handles path comparisons elsewhere. >From 6fe84eb5fecab14ca5ed411caa43d7a80527706e Mon Sep 17 00:00:00 2001 From: Li-Zheng-Rong <[email protected]> Date: Sat, 23 May 2026 18:47:44 +0800 Subject: [PATCH] [NFC] [clangd] [C++20] [Modules] Fix false duplicate module warning for equivalent paths When checking for multiple source files declaring the same module, the comparison used raw string equality on file paths. This causes false positives when the same file is represented by different but equivalent path strings. Use pathEqual(normalizePath(...), normalizePath(...)) instead to compare canonical paths, consistent with how clangd handles path comparisons elsewhere. --- clang-tools-extra/clangd/ProjectModules.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang-tools-extra/clangd/ProjectModules.cpp b/clang-tools-extra/clangd/ProjectModules.cpp index d3727171bff12..33cbc715e9659 100644 --- a/clang-tools-extra/clangd/ProjectModules.cpp +++ b/clang-tools-extra/clangd/ProjectModules.cpp @@ -247,7 +247,8 @@ ModuleDependencyScanner::scan(PathRef FilePath, auto [Iter, Inserted] = ModuleNameToSource.try_emplace( ScanningResult->Provides->ModuleName, FilePath); - if (!Inserted && Iter->second != FilePath) { + if (!Inserted && + !pathEqual(normalizePath(Iter->second), normalizePath(FilePath))) { elog("Detected multiple source files ({0}, {1}) declaring the same " "module: '{2}'. " "Now clangd may find the wrong source in such case.", _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
