diff --git a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp --- a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp +++ b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp @@ -19,6 +19,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/LineEditor/LineEditor.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Path.h" #include "llvm/Support/Signals.h" namespace clang { @@ -381,6 +382,10 @@ return -1; } + if (!ProjectRoot.empty() && + !llvm::StringRef(ProjectRoot).endswith(llvm::sys::path::get_separator())) + ProjectRoot += llvm::sys::path::get_separator(); + std::unique_ptr Index; reportTime(RemoteMode ? "Remote index client creation" : "Dex build", [&]() { Index = openIndex(IndexLocation); }); diff --git a/clang-tools-extra/clangd/index/remote/Client.cpp b/clang-tools-extra/clangd/index/remote/Client.cpp --- a/clang-tools-extra/clangd/index/remote/Client.cpp +++ b/clang-tools-extra/clangd/index/remote/Client.cpp @@ -76,7 +76,9 @@ : Stub(remote::SymbolIndex::NewStub(Channel)), ProtobufMarshaller(new Marshaller(/*RemoteIndexRoot=*/"", /*LocalIndexRoot=*/ProjectRoot)), - DeadlineWaitingTime(DeadlineTime) {} + DeadlineWaitingTime(DeadlineTime) { + assert(!ProjectRoot.empty()); + } void lookup(const clangd::LookupRequest &Request, llvm::function_ref Callback) const { diff --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp b/clang-tools-extra/clangd/tool/ClangdMain.cpp --- a/clang-tools-extra/clangd/tool/ClangdMain.cpp +++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp @@ -702,6 +702,10 @@ return 1; } if (!RemoteIndexAddress.empty()) { + if (!ProjectRoot.empty() && + !llvm::StringRef(ProjectRoot) + .endswith(llvm::sys::path::get_separator())) + ProjectRoot += llvm::sys::path::get_separator(); if (IndexFile.empty()) { log("Connecting to remote index at {0}", RemoteIndexAddress); StaticIdx = remote::getClient(RemoteIndexAddress, ProjectRoot);