[clangd] Treat 'auto' params as deduced if there's a single instantiation.
authorSam McCall <sam.mccall@gmail.com>
Fri, 11 Feb 2022 11:09:57 +0000 (12:09 +0100)
committerSam McCall <sam.mccall@gmail.com>
Mon, 21 Feb 2022 12:24:11 +0000 (13:24 +0100)
commitb9b6938183e837e66ff7450fb2b8a73dce5889c0
tree320ad6a3e186b735daece93f6b993e6a2198eddc
parent90faaf811f38f649a7629db8e9a1d1637e38c516
[clangd] Treat 'auto' params as deduced if there's a single instantiation.

This makes hover/go-to-definition/expand-auto etc work for auto params in many
common cases.
This includes when a generic lambda is passed to a function accepting
std::function. (The tests don't use this case, it requires a lot of setup).

Note that this doesn't affect the AST of the function body itself, cause its
nodes not to be dependent, improve code completion etc.
(These sort of improvements seem possible, in a similar "if there's a single
instantiation, traverse it instead of the primary template" way).

Fixes https://github.com/clangd/clangd/issues/493
Fixes https://github.com/clangd/clangd/issues/1015

Differential Revision: https://reviews.llvm.org/D119537
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
clang-tools-extra/clangd/unittests/ASTTests.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp
clang-tools-extra/clangd/unittests/tweaks/ExpandAutoTypeTests.cpp