diff --git a/clang-tools-extra/clangd/XRefs.cpp b/clang-tools-extra/clangd/XRefs.cpp --- a/clang-tools-extra/clangd/XRefs.cpp +++ b/clang-tools-extra/clangd/XRefs.cpp @@ -2112,6 +2112,7 @@ // FIXME: Consider also using AST information when feasible. RefsRequest Request; Request.IDs.insert(*ID); + Request.WantContainer = true; // We could restrict more specifically to calls by introducing a new RefKind, // but non-call references (such as address-of-function) can still be // interesting as they can indicate indirect calls. diff --git a/clang-tools-extra/clangd/index/Index.h b/clang-tools-extra/clangd/index/Index.h --- a/clang-tools-extra/clangd/index/Index.h +++ b/clang-tools-extra/clangd/index/Index.h @@ -72,6 +72,9 @@ /// choose to return less than this, e.g. it tries to avoid returning stale /// results. llvm::Optional Limit; + /// If set, populates the container of the reference. + /// Index implementations may chose to populate containers no matter what. + bool WantContainer = false; }; struct RelationsRequest { diff --git a/clang-tools-extra/clangd/index/remote/Index.proto b/clang-tools-extra/clangd/index/remote/Index.proto --- a/clang-tools-extra/clangd/index/remote/Index.proto +++ b/clang-tools-extra/clangd/index/remote/Index.proto @@ -47,6 +47,7 @@ repeated string ids = 1; optional uint32 filter = 2; optional uint32 limit = 3; + optional bool want_container = 4; } // The response is a stream of reference messages, and one terminating has_more diff --git a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp --- a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp +++ b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp @@ -122,6 +122,7 @@ Req.Filter = clangd::RefKind::All; if (Message->limit()) Req.Limit = Message->limit(); + Req.WantContainer = Message->want_container(); return Req; } @@ -239,6 +240,7 @@ RPCRequest.set_filter(static_cast(From.Filter)); if (From.Limit) RPCRequest.set_limit(*From.Limit); + RPCRequest.set_want_container(From.WantContainer); return RPCRequest; }