[PATCH] D72498: [clangd] Print underlying type for decltypes in hover
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 10 09:07:28 PST 2020
sammccall added a comment.
In D72498#1814286 <https://reviews.llvm.org/D72498#1814286>, @lh123 wrote:
> In D72498#1814008 <https://reviews.llvm.org/D72498#1814008>, @sammccall wrote:
>
> > I think i'm also comfortable with marking the linked bug as wontfix.
>
>
> The previous example is just minimal repo.
> I think it's worth fixing in this case.
>
> template<typename T1, typename T2>
> auto sum(T1 &t1, T2 &t2) ->decltype(t1 + t2))
> {
> return t1 + t2;
> }
>
Thanks for the clearer example! I agree that's one where it'd be nice to show the result type and hovering over `decltype` won't give it to you.
But note that this patch doesn't handle the important use case of decltype as return type, really!
imagine `cout << sum('c', 4)`, and you want to know what type the function call has.
The natural thing is to hover over the function call, you'll see "function `sum<char, int>` -> `decltype(t1 + t2)`" which is indeed pretty useless.
But this patch doesn't fix that behaviour, it only handles types of declarations.
@ilya-biryukov @kadircet what do you think about unwrapping decltype only when it's a return value (optional: of a function whose leading return type is auto) to narrowly catch this idiom?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72498/new/
https://reviews.llvm.org/D72498
More information about the cfe-commits
mailing list