llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-tools-extra

Author: None (95833)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/119350.diff


1 Files Affected:

- (modified) clang-tools-extra/clangd/PathMapping.cpp (+5-5) 


``````````diff
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);
 }

``````````

</details>


https://github.com/llvm/llvm-project/pull/119350
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to