[clangd] Unify printing policy for type hints
authorYounan Zhang <zyn7109@gmail.com>
Fri, 9 Jun 2023 10:51:47 +0000 (18:51 +0800)
committerYounan Zhang <zyn7109@gmail.com>
Tue, 13 Jun 2023 13:31:10 +0000 (21:31 +0800)
commit5cdb906f1e4093600f99aab8660e1536514a57e8
treeb63a153b76281563bfddc6ef348fd5dd1bb5ec4c
parent4cbedaeff54b8b8e967765333e5720d3760d30a2
[clangd] Unify printing policy for type hints

(This patch addresses the comment from https://reviews.llvm.org/D151785#4402460.)

Previously, we used a special printing policy that enabled `PrintCanonicalTypes`
to print type hints for structure bindings. This was intended to
eliminate type aliases like `tuple_element::type`. However, this also
caused TypePrinter to print default template arguments, which could
result in losing the ability to see types like `std::basic_string<char>`
if the fully expanded template-id exceeded the default inlay hint threshold.

Simply getting the canonical type at the call site could help us get rid of
the side effect.

This also merges overloaded `addTypeHint` into one function without
`PrintingPolicy`.

Reviewed By: nridge

Differential Revision: https://reviews.llvm.org/D152520
clang-tools-extra/clangd/InlayHints.cpp
clang-tools-extra/clangd/unittests/InlayHintTests.cpp