[PATCH] D72498: [clangd] Print underlying type for decltypes in hover
liu hui via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 10 19:43:30 PST 2020
lh123 added a comment.
> 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?
I think it's worth fixing in the declarations too.
int &bar(int a, int b);
template <typename Func, typename... Args>
auto call(Func &&func, Args &&... args)
-> decltype(func(std::forward<Args>(args)...));
template <typename T> void useRes(T &&t);
void foo() {
// Under c++11 we don't have decltype(auto), using auto here will lose
// reference.
decltype(call(bar, 5, 6)) res = call(bar, 5, 6);
if (res) {
// long code to process res
useRes(res); // User wants to know the type of res here.
} else {
// long code to process res
useRes(res);
}
}
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