HeuristicResolver is a code component in clangd used to aid code navigation features in templated code by heuristically associating dependent names with the declarations they’re likely to target.
It’s a standalone component with no dependencies on anything else in clangd. As of PR121313, it also has a unit test suite with no dependencies on anything else in clangd.
I would like to propose upstreaming HeuristicResolver to clang/lib/Sema
, with the public interface exposed in clang/include/Sema
.
The main advantage of doing so is that code outside of clangd would be able to use HeuristicResolver
. A notable example of in-tree code that would benefit from doing so is SemaCodeComplete.cpp
, where being able to use HeuristicResolver
would allow making various improvements to code completion behaviour in templated code, such as Code completion not working with smart pointers in template class header files in VS Code · Issue #810 · clangd/clangd · GitHub.
A secondary advantage would be better integration between HeuristicResolver
and other code in the clang libraries that performs similar tasks. For example, CXXRecordDecl::lookupDependentName() implements a subset of the same heuristics, and the two could share code after upstreaming.
I have a patch implementing the proposed upstreaming, and a draft patch implementing an example improvement to SemaCodeComplete.cpp
that uses HeuristicResolver
.
This was previously discussed in the clangd issue tracker.
Any feedback on the proposed upstreaming is welcome.