[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:12:46 PST 2022
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.
In the initial hover expression patch (https://reviews.llvm.org/D72500), we
disabled all literals.
There is some value on running hover on character literals (e.g. see the
int value of the char).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D117864
Files:
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/unittests/HoverTests.cpp
Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1224,7 +1224,6 @@
)cpp",
// literals
"auto x = t^rue;",
- "auto x = '^A';",
"auto x = ^(int){42};",
"auto x = ^42.;",
"auto x = ^42.0i;",
@@ -1250,6 +1249,11 @@
const char *const Code;
const std::function<void(HoverInfo &)> ExpectedBuilder;
} Cases[] = {
+ {"auto x = [['^A']]; // character literal",
+ [](HoverInfo &HI) {
+ HI.Name = "expression", HI.Type = "char";
+ HI.Value = "65 (0x41)";
+ }},
{
R"cpp(// Local variable
int main() {
Index: clang-tools-extra/clangd/Hover.cpp
===================================================================
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -725,7 +725,7 @@
bool isLiteral(const Expr *E) {
// Unfortunately there's no common base Literal classes inherits from
// (apart from Expr), therefore these exclusions.
- return llvm::isa<CharacterLiteral>(E) || llvm::isa<CompoundLiteralExpr>(E) ||
+ return llvm::isa<CompoundLiteralExpr>(E) ||
llvm::isa<CXXBoolLiteralExpr>(E) ||
llvm::isa<CXXNullPtrLiteralExpr>(E) ||
llvm::isa<FixedPointLiteral>(E) || llvm::isa<FloatingLiteral>(E) ||
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117864.401895.patch
Type: text/x-patch
Size: 1471 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220121/48bd0e90/attachment.bin>
More information about the cfe-commits
mailing list