[PATCH] D101915: [clangd][remote-client] Set HasMore to true for failure

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 5 08:48:35 PDT 2021


kadircet created this revision.
kadircet added a reviewer: kbobyrev.
Herald added subscribers: usaxena95, arphaman.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

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).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101915

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


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
@@ -64,7 +64,10 @@
                  StreamingCall<RequestT, ReplyT> RPCCall,
                  CallbackT Callback) const {
     updateConnectionStatus();
-    bool FinalResult = false;
+    // We initialize to true because stream might be broken before we see the
+    // final message. In such a case there are actually more results on the
+    // stream, but we couldn't get to them.
+    bool HasMore = true;
     trace::Span Tracer(RequestT::descriptor()->name());
     const auto RPCRequest = ProtobufMarshaller->toProtobuf(Request);
     SPAN_ATTACH(Tracer, "Request", RPCRequest.DebugString());
@@ -82,7 +85,7 @@
     unsigned FailedToParse = 0;
     while (Reader->Read(&Reply)) {
       if (!Reply.has_stream_result()) {
-        FinalResult = Reply.final_result().has_more();
+        HasMore = Reply.final_result().has_more();
         continue;
       }
       auto Response = ProtobufMarshaller->fromProtobuf(Reply.stream_result());
@@ -105,7 +108,7 @@
     SPAN_ATTACH(Tracer, "Successful", Successful);
     SPAN_ATTACH(Tracer, "Failed to parse", FailedToParse);
     updateConnectionStatus();
-    return FinalResult;
+    return HasMore;
   }
 
 public:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101915.343062.patch
Type: text/x-patch
Size: 1402 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210505/b7c2f263/attachment-0001.bin>


More information about the cfe-commits mailing list