[PATCH] D138300: [clangd] Support type hints for `decltype(expr)`

Vincent Hong via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 16 19:06:15 PST 2022


v1nh1shungry added a comment.

Thanks for the feedback!

> One high-level thought I had is: what if we attached the type hint to the closing `)` of the decltype (and had it pertain only to the `decltype(expr)`, not anything surrounding it like `const` or `&`)? It seems to me that this would both simplify the implementation, and allow us to show hints in places where `decltype` is used in a context unrelated to a variable or function declaration (for example, in something like `using Foo = A<B<decltype(expr), C>, D>`, if `decltype(expr)` was `int`, we would show `using Foo = A<B<decltype(expr) : int,  C>, D>`. What do you think about this approach?

I think this approach is better.

> I think showing type hints for `decltype(expr)` would be a nice enhancement. @v1nh1shungry, are you interested in working further on this?

Sure!



================
Comment at: clang-tools-extra/clangd/unittests/InlayHintTests.cpp:1155
+    // FIXME: Nice to show `: int &`
+    decltype((i)) $a[[a]] = i;
+  )cpp",
----------------
The only concern I have is how to deal with this situation.

When I wrote this patch I thought maybe I could remove the `&` and figure out the underlying type of `decltype(0)` recursively and then add the `&` back. But at that time I couldn't find a way to get the referenced type or the pointee type.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138300/new/

https://reviews.llvm.org/D138300



More information about the cfe-commits mailing list