[llvm-branch-commits] [clang-tools-extra] 2b62e62 - [clangd] Fix windows path handling in .clang-tidy parsing

Sam McCall via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Dec 18 17:28:57 PST 2020


Author: Sam McCall
Date: 2020-12-19T02:24:25+01:00
New Revision: 2b62e62328841b7d2dc01e390e13fb9151d06263

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

LOG: [clangd] Fix windows path handling in .clang-tidy parsing

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/TidyProvider.cpp b/clang-tools-extra/clangd/TidyProvider.cpp
index c12dab7e2e5e..0a9f12221287 100644
--- a/clang-tools-extra/clangd/TidyProvider.cpp
+++ b/clang-tools-extra/clangd/TidyProvider.cpp
@@ -106,12 +106,17 @@ class DotClangTidyTree {
     llvm::SmallVector<DotClangTidyCache *> Caches;
     {
       std::lock_guard<std::mutex> Lock(Mu);
-      for (auto I = path::begin(Parent, path::Style::posix),
-                E = path::end(Parent);
-           I != E; ++I) {
+      for (auto I = path::begin(Parent), E = path::end(Parent); I != E; ++I) {
         assert(I->end() >= Parent.begin() && I->end() <= Parent.end() &&
                "Canonical path components should be substrings");
         llvm::StringRef Ancestor(Parent.begin(), I->end() - Parent.begin());
+#ifdef _WIN32
+        // C:\ is an ancestor, but skip its (relative!) parent C:.
+        if (Ancestor.size() == 2 && Ancestor.back() == ':')
+          continue;
+#endif
+        assert(path::is_absolute(Ancestor));
+
         auto It = Cache.find(Ancestor);
 
         // Assemble the actual config file path only if needed.


        


More information about the llvm-branch-commits mailing list