Skip to content

Commit 5bbf6ad

Browse files
committed
Add an option to fill container for ref
This allows index implementations to fill container details when required specially when computing containerID is expensive. Differential Revision: https://reviews.llvm.org/D125925
1 parent d633dbd commit 5bbf6ad

File tree

4 files changed

+7
-0
lines changed

4 files changed

+7
-0
lines changed

clang-tools-extra/clangd/XRefs.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2112,6 +2112,7 @@ incomingCalls(const CallHierarchyItem &Item, const SymbolIndex *Index) {
21122112
// FIXME: Consider also using AST information when feasible.
21132113
RefsRequest Request;
21142114
Request.IDs.insert(*ID);
2115+
Request.WantContainer = true;
21152116
// We could restrict more specifically to calls by introducing a new RefKind,
21162117
// but non-call references (such as address-of-function) can still be
21172118
// interesting as they can indicate indirect calls.

clang-tools-extra/clangd/index/Index.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ struct RefsRequest {
7272
/// choose to return less than this, e.g. it tries to avoid returning stale
7373
/// results.
7474
llvm::Optional<uint32_t> Limit;
75+
/// If set, populates the container of the reference.
76+
/// Index implementations may chose to populate containers no matter what.
77+
bool WantContainer = false;
7578
};
7679

7780
struct RelationsRequest {

clang-tools-extra/clangd/index/remote/Index.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ message RefsRequest {
4747
repeated string ids = 1;
4848
optional uint32 filter = 2;
4949
optional uint32 limit = 3;
50+
optional bool want_container = 4;
5051
}
5152

5253
// The response is a stream of reference messages, and one terminating has_more

clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ Marshaller::fromProtobuf(const RefsRequest *Message) {
122122
Req.Filter = clangd::RefKind::All;
123123
if (Message->limit())
124124
Req.Limit = Message->limit();
125+
Req.WantContainer = Message->want_container();
125126
return Req;
126127
}
127128

@@ -239,6 +240,7 @@ RefsRequest Marshaller::toProtobuf(const clangd::RefsRequest &From) {
239240
RPCRequest.set_filter(static_cast<uint32_t>(From.Filter));
240241
if (From.Limit)
241242
RPCRequest.set_limit(*From.Limit);
243+
RPCRequest.set_want_container(From.WantContainer);
242244
return RPCRequest;
243245
}
244246

0 commit comments

Comments
 (0)