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) ||
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) ||
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits