[clangd] Fix windows path handling in .clang-tidy parsing
authorSam McCall <sam.mccall@gmail.com>
Sat, 19 Dec 2020 01:23:39 +0000 (02:23 +0100)
committerSam McCall <sam.mccall@gmail.com>
Sat, 19 Dec 2020 01:24:25 +0000 (02:24 +0100)
clang-tools-extra/clangd/TidyProvider.cpp

index c12dab7..0a9f122 100644 (file)
@@ -106,12 +106,17 @@ public:
     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.