Author: Li-Zheng-Rong
Date: 2026-05-26T06:05:17Z
New Revision: fe3d6b051b31f5794cd29818acb9203dbb7dd6f4

URL: 
https://github.com/llvm/llvm-project/commit/fe3d6b051b31f5794cd29818acb9203dbb7dd6f4
DIFF: 
https://github.com/llvm/llvm-project/commit/fe3d6b051b31f5794cd29818acb9203dbb7dd6f4.diff

LOG: [NFC] [clangd] [C++20] [Modules] Fix false duplicate module warning for 
equivalent paths (#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.

Added: 
    

Modified: 
    clang-tools-extra/clangd/ProjectModules.cpp

Removed: 
    


################################################################################
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

Reply via email to