[PATCH] D120115: [clangd] Tweak --query-driver to ignore slash direction on windows

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 18 04:28:40 PST 2022


sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

See https://github.com/clangd/clangd/issues/1022


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120115

Files:
  clang-tools-extra/clangd/QueryDriverDatabase.cpp


Index: clang-tools-extra/clangd/QueryDriverDatabase.cpp
===================================================================
--- clang-tools-extra/clangd/QueryDriverDatabase.cpp
+++ clang-tools-extra/clangd/QueryDriverDatabase.cpp
@@ -38,12 +38,10 @@
 #include "clang/Basic/TargetOptions.h"
 #include "clang/Driver/Types.h"
 #include "clang/Tooling/CompilationDatabase.h"
-#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/iterator_range.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
@@ -276,6 +274,10 @@
         // Single star, accept any sequence without a slash.
         RegStream << "[^/]*";
       }
+    } else if (llvm::sys::path::is_separator(Glob[I]) &&
+               llvm::sys::path::is_separator('/') &&
+               llvm::sys::path::is_separator('\\')) {
+      RegStream << R"([/\\])"; // Accept either slash on windows.
     } else {
       RegStream << llvm::Regex::escape(Glob.substr(I, 1));
     }
@@ -293,6 +295,7 @@
   for (llvm::StringRef Glob : Globs)
     RegTexts.push_back(convertGlobToRegex(Glob));
 
+  // Tempting to pass IgnoreCase, but we don't the FS sensitivity precisely.
   llvm::Regex Reg(llvm::join(RegTexts, "|"));
   assert(Reg.isValid(RegTexts.front()) &&
          "Created an invalid regex from globs");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120115.409900.patch
Type: text/x-patch
Size: 1455 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220218/24d35998/attachment.bin>


More information about the cfe-commits mailing list