[PATCH] D117864: [clangd] Enable hover on character literal.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 21 01:32:01 PST 2022


hokein added inline comments.


================
Comment at: clang-tools-extra/clangd/Hover.cpp:733
          llvm::isa<ImaginaryLiteral>(E) || llvm::isa<IntegerLiteral>(E) ||
          llvm::isa<StringLiteral>(E) || llvm::isa<UserDefinedLiteral>(E);
 }
----------------
there may be some value to enable StringLiteral as well (e.g. see the length of the string), but it seems to work partially:

- `auto char_ptr = "ab^c"; // fails`
- `char abc[] = "a^bc"; // works`
- `const char* ptr = "a^bc"; // fails"`
- `"a^bc"; // fails` 
- `func("a^bc"); // fails`

Looks like the reason is that `EvaluateAsRValue` fails on a `lvalue` StringLiteral. It'd require a bit of work to make it useful for common cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117864



More information about the cfe-commits mailing list