diff --git a/clang-tools-extra/clangd/index/remote/Index.proto b/clang-tools-extra/clangd/index/remote/Index.proto index 689ef9d44ee409..3e39724e320860 100644 --- a/clang-tools-extra/clangd/index/remote/Index.proto +++ b/clang-tools-extra/clangd/index/remote/Index.proto @@ -133,7 +133,7 @@ message Relation { } message ContainedRefsRequest { - required string id = 1; + optional string id = 1; optional uint32 limit = 2; } @@ -145,7 +145,7 @@ message ContainedRefsReply { } message ContainedRef { - required SymbolLocation location = 1; - required uint32 kind = 2; - required string symbol = 3; + optional SymbolLocation location = 1; + optional uint32 kind = 2; + optional string symbol = 3; } diff --git a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp index a80d12347d48d2..d8d3b64a5ac18c 100644 --- a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp +++ b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp @@ -129,6 +129,8 @@ Marshaller::fromProtobuf(const RefsRequest *Message) { llvm::Expected Marshaller::fromProtobuf(const ContainedRefsRequest *Message) { clangd::ContainedRefsRequest Req; + if (!Message->has_id()) + return error("ContainedRefsRequest requires an id."); auto ID = SymbolID::fromStr(Message->id()); if (!ID) return ID.takeError(); @@ -207,6 +209,12 @@ llvm::Expected Marshaller::fromProtobuf(const Ref &Message) { llvm::Expected Marshaller::fromProtobuf(const ContainedRef &Message) { clangd::ContainedRefsResult Result; + if (!Message.has_location()) + return error("ContainedRef must have a location."); + if (!Message.has_kind()) + return error("ContainedRef must have a kind."); + if (!Message.has_symbol()) + return error("ContainedRef must have a symbol."); auto Location = fromProtobuf(Message.location()); if (!Location) return Location.takeError();