[clang-tools-extra] [clangd][RFC] Add container field to remote index Refs grpc method (PR #71605)

via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 20 11:47:52 PST 2023


https://github.com/tdupes updated https://github.com/llvm/llvm-project/pull/71605

>From d2a6bec499b7163cfa97104113d0b7e297fe2f92 Mon Sep 17 00:00:00 2001
From: dup <dup at fb.com>
Date: Fri, 3 Nov 2023 09:03:24 -0700
Subject: [PATCH 1/2] Add container field to remote index Refs grpc method

---
 clang-tools-extra/clangd/index/remote/Index.proto            | 1 +
 .../clangd/index/remote/marshalling/Marshalling.cpp          | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/clang-tools-extra/clangd/index/remote/Index.proto b/clang-tools-extra/clangd/index/remote/Index.proto
index 3072299d8f345f2..33bf095d88598f5 100644
--- a/clang-tools-extra/clangd/index/remote/Index.proto
+++ b/clang-tools-extra/clangd/index/remote/Index.proto
@@ -81,6 +81,7 @@ message Symbol {
 message Ref {
   optional SymbolLocation location = 1;
   optional uint32 kind = 2;
+  optional string container = 3;
 }
 
 message SymbolInfo {
diff --git a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
index 7e31ada18a65797..578b20f27f43f49 100644
--- a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
+++ b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
@@ -189,6 +189,10 @@ llvm::Expected<clangd::Ref> Marshaller::fromProtobuf(const Ref &Message) {
     return Location.takeError();
   Result.Location = *Location;
   Result.Kind = static_cast<RefKind>(Message.kind());
+  auto ContainerID = SymbolID::fromStr(Message.container());
+  if (!ContainerID)
+    return ContainerID.takeError();
+  Result.Container = *ContainerID;
   return Result;
 }
 
@@ -296,6 +300,7 @@ llvm::Expected<Ref> Marshaller::toProtobuf(const clangd::Ref &From) {
   if (!Location)
     return Location.takeError();
   *Result.mutable_location() = *Location;
+  Result.set_container(From.Container.str());
   return Result;
 }
 

>From 80d8c4fb3b93efe932297b57d5aa89841dd4d655 Mon Sep 17 00:00:00 2001
From: Thomas <t at dupes.io>
Date: Mon, 20 Nov 2023 13:45:11 -0600
Subject: [PATCH 2/2] Update remote marshalling tests to reflect new refs
 container field

---
 clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp b/clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
index a2b31698a059a90..85e79eae331bc1c 100644
--- a/clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -223,6 +223,7 @@ TEST(RemoteMarshallingTest, RefSerialization) {
   Location.FileURI = testPathURI(
       "llvm-project/llvm/clang-tools-extra/clangd/Protocol.h", Strings);
   Ref.Location = Location;
+  Ref.Container = llvm::cantFail(SymbolID::fromStr("0000000000000001"));
 
   Marshaller ProtobufMarshaller(testPath("llvm-project/"),
                                 testPath("llvm-project/"));



More information about the cfe-commits mailing list