[clang-tools-extra] [clangd] Add inlay hints for default function arguments and implicit lambda captures (PR #95712)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 16 22:37:37 PDT 2024


https://github.com/zyn0217 commented:

My two cents:

While I appreciate the value of inspecting more semantic information about lambdas, I still have mixed feelings about user experience.

Admittedly, presenting implicitly captured variables provides users with insight into ODR-used variables, but I'm unsure about our strategy: We would probably end up showing too many hints inside the lambda capture, which would visually elongate the lambda header and distract users from reading.

Indeed, we have a configuration entry to restrict the length, but I feel that's insufficient (Although we're baking it with TypeNameLimit currently, which is also inappropriate). For example, a user might have a lambda capturing several variables named in single letters e.g. a-z. As a result, we probably eventually display `[&: a, b, c, d, e, f, g, ...](...)`, which is IMO too spammy.

That said, I wonder if we can implement the capture stuff in hovers instead. >From what I can think of, we present something e.g.
```cpp
// implicitly captured by reference/copy:
int a;
std::string s;
...
```
when user hovers over the capture defaults.

(I don't have a strong opinion on the hints for default arguments. It would also be great to hear @HighCommander4 and @kadircet's input.)

https://github.com/llvm/llvm-project/pull/95712


More information about the cfe-commits mailing list