[clangd] Improve inlay hints of things expanded from macros
authorSam McCall <sam.mccall@gmail.com>
Thu, 15 Sep 2022 22:41:32 +0000 (00:41 +0200)
committerTobias Hieta <tobias@hieta.se>
Mon, 10 Oct 2022 06:49:22 +0000 (08:49 +0200)
commit359ef0c932404d31347ce25895fdcadee1004381
tree64c862e352ecbe157dabf5ba1a433e59921309ac
parentbd5722b87b5aa1b8286762af7f29b6aae669dee1
[clangd] Improve inlay hints of things expanded from macros

When we aim a hint at some expanded tokens, we're only willing to attach it
to spelled tokens that exactly corresponde.

e.g.
int zoom(int x, int y, int z);
int dummy = zoom(NUMBERS);

Here we want to place a hint "x:" on the expanded "1", but we shouldn't
be willing to place it on NUMBERS, because it doesn't *exactly*
correspond (it has more tokens).

Fortunately we don't even have to implement this algorithm from scratch,
TokenBuffer has it.

Fixes https://github.com/clangd/clangd/issues/1289
Fixes https://github.com/clangd/clangd/issues/1118
Fixes https://github.com/clangd/clangd/issues/1018

Differential Revision: https://reviews.llvm.org/D133982

(cherry picked from commit 924974a3a13b03090d04860f209ce11b3d9d00a6)
clang-tools-extra/clangd/InlayHints.cpp
clang-tools-extra/clangd/unittests/InlayHintTests.cpp