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/index/remote/marshalling/Marshalling.cpp b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp --- a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp +++ b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp @@ -59,14 +59,16 @@ assert(llvm::sys::path::is_absolute(RemoteIndexRoot)); assert(RemoteIndexRoot == llvm::sys::path::convert_to_slash(RemoteIndexRoot)); - assert(RemoteIndexRoot.endswith(llvm::sys::path::get_separator())); this->RemoteIndexRoot = RemoteIndexRoot.str(); + if (!RemoteIndexRoot.endswith(llvm::sys::path::get_separator())) + *this->RemoteIndexRoot += llvm::sys::path::get_separator(); } if (!LocalIndexRoot.empty()) { assert(llvm::sys::path::is_absolute(LocalIndexRoot)); assert(LocalIndexRoot == llvm::sys::path::convert_to_slash(LocalIndexRoot)); - assert(LocalIndexRoot.endswith(llvm::sys::path::get_separator())); this->LocalIndexRoot = LocalIndexRoot.str(); + if (!LocalIndexRoot.endswith(llvm::sys::path::get_separator())) + *this->LocalIndexRoot += llvm::sys::path::get_separator(); } assert(!RemoteIndexRoot.empty() || !LocalIndexRoot.empty()); }