[clangd][remote] Make sure relative paths are absolute with respect to posix style
authorKadir Cetinkaya <kadircet@google.com>
Tue, 29 Sep 2020 18:15:03 +0000 (20:15 +0200)
committerKadir Cetinkaya <kadircet@google.com>
Wed, 30 Sep 2020 09:08:49 +0000 (11:08 +0200)
Relative paths received from the server are always in posix style. So
we need to ensure they are relative using that style, and not the native one.

Differential Revision: https://reviews.llvm.org/D88507

clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp

index 31ce4a4..d61848f 100644 (file)
@@ -299,7 +299,7 @@ Marshaller::relativePathToURI(llvm::StringRef RelativePath) {
   assert(RelativePath == llvm::sys::path::convert_to_slash(RelativePath));
   if (RelativePath.empty())
     return error("Empty relative path.");
-  if (llvm::sys::path::is_absolute(RelativePath))
+  if (llvm::sys::path::is_absolute(RelativePath, llvm::sys::path::Style::posix))
     return error("RelativePath '{0}' is absolute.", RelativePath);
   llvm::SmallString<256> FullPath = llvm::StringRef(*LocalIndexRoot);
   llvm::sys::path::append(FullPath, RelativePath);