Skip to content

Commit 888307e

Browse files
committed
[clangd][remote-client] Set HasMore to true for failure
Currently client was setting the HasMore to true iff stream said so. Hence if we had a broken stream for whatever reason (e.g. hitting deadline for a huge response), HasMore would be false, which is semantically incorrect (e.g. will throw rename off). Differential Revision: https://reviews.llvm.org/D101915
1 parent daf3cb3 commit 888307e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

clang-tools-extra/clangd/index/remote/Client.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ class IndexClient : public clangd::SymbolIndex {
6464
StreamingCall<RequestT, ReplyT> RPCCall,
6565
CallbackT Callback) const {
6666
updateConnectionStatus();
67-
bool FinalResult = false;
67+
// We initialize to true because stream might be broken before we see the
68+
// final message. In such a case there are actually more results on the
69+
// stream, but we couldn't get to them.
70+
bool HasMore = true;
6871
trace::Span Tracer(RequestT::descriptor()->name());
6972
const auto RPCRequest = ProtobufMarshaller->toProtobuf(Request);
7073
SPAN_ATTACH(Tracer, "Request", RPCRequest.DebugString());
@@ -82,7 +85,7 @@ class IndexClient : public clangd::SymbolIndex {
8285
unsigned FailedToParse = 0;
8386
while (Reader->Read(&Reply)) {
8487
if (!Reply.has_stream_result()) {
85-
FinalResult = Reply.final_result().has_more();
88+
HasMore = Reply.final_result().has_more();
8689
continue;
8790
}
8891
auto Response = ProtobufMarshaller->fromProtobuf(Reply.stream_result());
@@ -105,7 +108,7 @@ class IndexClient : public clangd::SymbolIndex {
105108
SPAN_ATTACH(Tracer, "Successful", Successful);
106109
SPAN_ATTACH(Tracer, "Failed to parse", FailedToParse);
107110
updateConnectionStatus();
108-
return FinalResult;
111+
return HasMore;
109112
}
110113

111114
public:

0 commit comments

Comments
 (0)