[PATCH] D72874: [clangd] Add a textual fallback for go-to-definition

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 2 13:44:00 PST 2020


sammccall added a comment.

In D72874#1901606 <https://reviews.llvm.org/D72874#1901606>, @nridge wrote:

> The "dependent code" use case is a pretty important one in my eyes.
>
> In one of the codebases I work on, we have a fair amount of code like this:


Yep, fair enough. And I don't think that this is so bad for say `DependentDeclRefExpr`, where we're already doing heuristic stuff (and the user can reasonably understand that we might).
I'm more concerned that it might trigger at arbitrary times, like say on `[[^noreturn]] void abort();`.

But we can distinguish these cases! `SelectionTree` recognizes `DependentDeclRefExpr` and friends even if `targetDecl` can't resolve them. So I think we can use a whitelist: the AST part of locateSymbol reports the type of node that owned TouchedIdentifier, and if it's one of the types we want to use textual fallback for, then we go ahead with the fallback code (in addition to the cases I mentioned where the touched word doesn't turn out to be a real identifier).
We can even try to glean more info, e.g. if it's a `CXXDependentScopeMemberExpr` then we can filter out non-member index results.

(Tactically I think it makes sense to add the basic fallback logic, and follow up with the dependent-code entrypoints, but up to you)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72874/new/

https://reviews.llvm.org/D72874





More information about the cfe-commits mailing list