[PATCH] D93314: [clangd] go-to-definition on auto unwraps array/pointer types
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 16 03:31:16 PST 2020
sammccall planned changes to this revision.
sammccall added a comment.
In D93314#2455884 <https://reviews.llvm.org/D93314#2455884>, @qchateau wrote:
> Ah good catch, I agree this is the behavior we want.
>
> Concerning cases like `unique_ptr<T>`, the only generic behavior I can think of would be to suggest multiple `LocatedSymbol` when `auto` is deduced to a template class: the template class itself, and all its template type parameters.
Right. There are not-completely-generic options too though :-)
I'm inclined to agree that `unique_ptr<MemoryBuffer>` should resolve to both `unique_ptr` and `MemoryBuffer`.
But not `std::default_deleter`, and probably not even a custom deleter.
Similarly, maybe `vector<MemoryBuffer>` should resolve to both, but I'm not sure that holds for all templates (e.g. `lock_guard`).
So I'm leaning towards defining these behaviors for **pointers and containers** rather than **templates** per se. There's a nice symmetry with the raw pointer and array types that this patch.
(We have some precedent and code for detecting smart pointers, see `getPointeeType()` in FindTarget.cpp.)
We could land this as-is (just handling the built-in types) but it will need some structural changes for dealing with multiple results (including recursive cases like vector<Foo*>) so I'll take a stab at doing all that at once.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93314/new/
https://reviews.llvm.org/D93314
More information about the cfe-commits
mailing list