nridge added inline comments.

================
Comment at: clang-tools-extra/clangd/unittests/InlayHintTests.cpp:1155
+    // FIXME: Nice to show `: int &`
+    decltype((i)) $a[[a]] = i;
+  )cpp",
----------------
v1nh1shungry wrote:
> 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.
This is a problem we already have for `auto`. For example, if you write: 

```
auto i = decltype(0)();
```

the type hint for the `auto` is `decltype(0)`.

The reason is that we are printing the type with `TypeHintPolicy`, which has 
`PrintCanonicalTypes=false` (the default). This means the type is printed 
without "type sugar" (e.g. decltype, typedefs) being replaced with their 
"underlying type".

We could alternatively print it with `PrintCanonicalTypes=true`, which would 
make the hint given in this case better, but it would make other cases worse 
(e.g. replacing `std::string` with `std::basic_string<...>`).

For the purposes of this patch, I think it's fine to just live with whatever 
type is printed with the current printing policy.

If we want to make improvements in this area, we can do that in a separate 
patch, and in a way that affects both `auto` and `decltype(expr)`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138300

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to