[PATCH] D70359: [clangd] Show values of more expressions on hover
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 18 13:54:59 PST 2019
sammccall added inline comments.
================
Comment at: clang-tools-extra/clangd/Hover.cpp:255
+ // Show enums symbolically, not numerically like APValue::printPretty().
+ if (E->getType()->isEnumeralType() &&
+ Constant.Val.getInt().getMinSignedBits() <= 64) {
----------------
kadircet wrote:
> both `Constant.Val.getInt` and `ECD->getInitVal` are `APSInt` and it has an `operator==`, why cast to `int64_t` in between?
operator== asserts(!) that the widths are equal. (And they're not always)
added a comment
================
Comment at: clang-tools-extra/clangd/Hover.cpp:423
+ // - certain expressions (sizeof etc)
+ // - built-in types
}
----------------
lh123 wrote:
> lh123 wrote:
> > sammccall wrote:
> > > lh123 wrote:
> > > > I think we should also support hover on literal.
> > > sure - can you explain what you'd like to see/when you'd expect it to be useful?
> > such as:
> > 1. Hovering on "abc" shows char[4], we can get the length information of the string.
> > 2. Get actual type for user-defined literal types.
> > ```c++
> > struct foo {};
> > struct foo {};
> >
> > foo operator""_foo(unsigned long long v) { return {}; }
> >
> > int main() {
> > 1_foo;
> > }
> >
> > ```
> >
> ```
> struct foo {};
>
> foo operator""_foo(unsigned long long v) { return {}; }
>
> int main() {
> 1_foo;
> }
> ```
Added a comment about literals.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D70359/new/
https://reviews.llvm.org/D70359
More information about the cfe-commits
mailing list