kbobyrev updated this revision to Diff 284609. kbobyrev marked an inline comment as done. kbobyrev added a comment.
Handle slash appending in Marshaller. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D85711/new/ https://reviews.llvm.org/D85711 Files: clang-tools-extra/clangd/index/remote/Client.cpp clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp Index: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp =================================================================== --- clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp +++ 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().str(); } 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().str(); } assert(!RemoteIndexRoot.empty() || !LocalIndexRoot.empty()); } Index: clang-tools-extra/clangd/index/remote/Client.cpp =================================================================== --- clang-tools-extra/clangd/index/remote/Client.cpp +++ 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<void(const clangd::Symbol &)> Callback) const {
Index: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp =================================================================== --- clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp +++ 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().str(); } 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().str(); } assert(!RemoteIndexRoot.empty() || !LocalIndexRoot.empty()); } Index: clang-tools-extra/clangd/index/remote/Client.cpp =================================================================== --- clang-tools-extra/clangd/index/remote/Client.cpp +++ 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<void(const clangd::Symbol &)> Callback) const {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits