[PATCH] D121286: [clangd] Test against path insensitivity
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 9 05:55:49 PST 2022
kadircet created this revision.
Herald added subscribers: usaxena95, arphaman.
Herald added a project: All.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D121286
Files:
clang-tools-extra/clangd/HeaderSourceSwitch.cpp
clang-tools-extra/clangd/unittests/TestFS.cpp
Index: clang-tools-extra/clangd/unittests/TestFS.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/TestFS.cpp
+++ 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
Index: clang-tools-extra/clangd/HeaderSourceSwitch.cpp
===================================================================
--- clang-tools-extra/clangd/HeaderSourceSwitch.cpp
+++ 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<int> 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());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121286.414081.patch
Type: text/x-patch
Size: 1499 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220309/6649f11c/attachment.bin>
More information about the cfe-commits
mailing list