diff --git a/clang-tools-extra/clangd/HeaderSourceSwitch.cpp b/clang-tools-extra/clangd/HeaderSourceSwitch.cpp --- a/clang-tools-extra/clangd/HeaderSourceSwitch.cpp +++ b/clang-tools-extra/clangd/HeaderSourceSwitch.cpp @@ -11,6 +11,7 @@ #include "SourceCode.h" #include "index/SymbolCollector.h" #include "support/Logger.h" +#include "support/Path.h" #include "clang/AST/Decl.h" namespace clang { @@ -82,7 +83,7 @@ llvm::StringMap Candidates; // Target path => score. auto AwardTarget = [&](const char *TargetURI) { if (auto TargetPath = URI::resolve(TargetURI, OriginalFile)) { - if (*TargetPath != OriginalFile) // exclude the original file. + if (!pathEqual(*TargetPath, OriginalFile)) // exclude the original file. ++Candidates[*TargetPath]; } else { elog("Failed to resolve URI {0}: {1}", TargetURI, TargetPath.takeError()); diff --git a/clang-tools-extra/clangd/unittests/TestFS.cpp b/clang-tools-extra/clangd/unittests/TestFS.cpp --- a/clang-tools-extra/clangd/unittests/TestFS.cpp +++ b/clang-tools-extra/clangd/unittests/TestFS.cpp @@ -73,7 +73,11 @@ const char *testRoot() { #ifdef _WIN32 - return "C:\\clangd-test"; + // On windows paths are insensitive, simulate that behaviour by toggling + // capitalization for drive-letter on each call. + static bool CallParity = false; + CallParity = !CallParity; + return CallParity ? "C:\\clangd-test" : "c:\\clangd-test"; #else return "/clangd-test"; #endif