[clangd-dev] Querying the index for derived classes

Nathan Ridge via clangd-dev clangd-dev at lists.llvm.org
Sun Jan 13 10:25:19 PST 2019


> We do have plans to add some type information to the index for the 
> purposes of code completion ranking (boost results that have the 
> right type).
> This will need to include the base types (e.g. so that when a Shape& is 
> expected, a Circle& will match it). So maybe we can use the same data 
> and query for (kind=type && type=SomeBase) to find derived types.
> Ilya is working on this, this might be a nice solution without 
> expanding the index, if expected-types ranking and subtypes don't 
> turn out to be too divergent.

Thanks, this is an interesting direction to explore.

I looked briefly at the expected-types patches that have landed so far. Do I understand correctly that there are plans to expand the field Symbol::Type to also encode the types of the base classes?

> One limitation here is that subtypes are not strictly a 
> symbol->symbol relationship when templates are considered. 

Good point. Indeed, in the other C++ indexer that I'm familiar with (Eclipse CDT's), types have their own representation in the index (which includes a way to represent e.g. template specializations), and bases use that representation.

> Regarding Apple's index-while-build: 
> [...]
> We do use a bit of the infrastructure to walk ASTs.

Would that be the facilities in the "clang/Index/*" headers that e.g. SymbolCollector uses?

Thanks,
Nate


More information about the clangd-dev mailing list