This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Show values of more expressions on hover
ClosedPublic

Authored by sammccall on Nov 16 2019, 1:52 PM.

Diff Detail

Event Timeline

sammccall created this revision.Nov 16 2019, 1:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 16 2019, 1:52 PM

Build result: fail - 60143 tests passed, 2 failed and 729 were skipped.

failed: Clangd Unit Tests._/ClangdTests/FindExplicitReferencesTest.All
failed: LLVM.Bindings/Go/go.test

Log files: console-log.txt, CMakeCache.txt

lh123 added a subscriber: lh123.Nov 17 2019, 12:18 AM
lh123 added inline comments.
clang-tools-extra/clangd/Hover.cpp
423

I think we should also support hover on literal.

sammccall marked an inline comment as done.Nov 18 2019, 1:03 AM
sammccall added inline comments.
clang-tools-extra/clangd/Hover.cpp
423

sure - can you explain what you'd like to see/when you'd expect it to be useful?

lh123 added inline comments.Nov 18 2019, 1:44 AM
clang-tools-extra/clangd/Hover.cpp
423

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;
}
lh123 added inline comments.Nov 18 2019, 1:47 AM
clang-tools-extra/clangd/Hover.cpp
423
struct foo {};

foo operator""_foo(unsigned long long v) { return {}; }

int main() {
    1_foo;
}
kadircet marked an inline comment as done.Nov 18 2019, 2:13 AM
kadircet added inline comments.
clang-tools-extra/clangd/Hover.cpp
247

nit extract E->getType() into a variable

255

both Constant.Val.getInt and ECD->getInitVal are APSInt and it has an operator==, why cast to int64_t in between?

clang-tools-extra/clangd/unittests/HoverTests.cpp
278

wow, that's hilarious.

450

what about GREEN (1) ?

sammccall updated this revision to Diff 229916.Nov 18 2019, 1:28 PM
sammccall marked 5 inline comments as done.

GREEN -> GREEN (1)

sammccall added inline comments.Nov 18 2019, 1:53 PM
clang-tools-extra/clangd/Hover.cpp
255

operator== asserts(!) that the widths are equal. (And they're not always)
added a comment

423

Added a comment about literals.

Build result: fail - 60136 tests passed, 2 failed and 729 were skipped.

failed: LLVM.CodeGen/NVPTX/vectorize-misaligned.ll
failed: LLVM.Transforms/LoadStoreVectorizer/AMDGPU/merge-stores.ll

Log files: console-log.txt, CMakeCache.txt

it feels like rebasing went wrong :(

sammccall updated this revision to Diff 230058.Nov 19 2019, 6:21 AM

Fix rebase

kadircet accepted this revision.Nov 19 2019, 6:28 AM

LGTM, thanks!

This revision is now accepted and ready to land.Nov 19 2019, 6:28 AM
This revision was automatically updated to reflect the committed changes.

Build result: pass - 60178 tests passed, 0 failed and 732 were skipped.
Log files: console-log.txt, CMakeCache.txt