https://github.com/95833 created 
https://github.com/llvm/llvm-project/pull/119085

path::is_absolute(Path, path::Style::windows) will return false leading to an 
error when the path appears in the root driver form, for example: 
path-mappings=E:=/mnt/e 

This modification also potentially provides support for WSL paths. for example: 
path-mappings=\\wsl.localhost/usr=/usr

>From 1a37796fbb624a54b00cfff42674fbfa79616f61 Mon Sep 17 00:00:00 2001
From: root <987004...@qq.com>
Date: Sun, 8 Dec 2024 01:19:59 +0800
Subject: [PATCH] fix parse windows driver and wsl path

---
 clang-tools-extra/clangd/PathMapping.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/clang-tools-extra/clangd/PathMapping.cpp 
b/clang-tools-extra/clangd/PathMapping.cpp
index 4b93ff2c60c5c6..48a936867a738a 100644
--- a/clang-tools-extra/clangd/PathMapping.cpp
+++ b/clang-tools-extra/clangd/PathMapping.cpp
@@ -150,11 +150,11 @@ llvm::Expected<std::string> parsePath(llvm::StringRef 
Path) {
   if (path::is_absolute(Path, path::Style::posix)) {
     return std::string(Path);
   }
-  if (path::is_absolute(Path, path::Style::windows)) {
-    std::string Converted = path::convert_to_slash(Path, path::Style::windows);
-    if (Converted.front() != '/')
-      Converted = "/" + Converted;
-    return Converted;
+  llvm::StringRef Root = path::root_name(Path, path::Style::windows);
+  if (!Root.empty()) {
+    std::string Converted = "/";
+    return Converted.append(Root)
+          .append(path::convert_to_slash(Path.substr(Root.size()), 
path::Style::windows));
   }
   return error("Path not absolute: {0}", Path);
 }

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to