[PATCH] D71544: [clangd] Improve printing of lambda names
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 16 05:50:18 PST 2019
kadircet created this revision.
kadircet added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay.
Herald added a project: clang.
Clangd was printing lambdas as `(anonymous class)` before, we can
improve it by at least printing `(lambda)` instead.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D71544
Files:
clang-tools-extra/clangd/AST.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
@@ -362,8 +362,7 @@
}
)cpp",
[](HoverInfo &HI) {
- // FIXME: Special case lambdas.
- HI.Name = "(anonymous class)";
+ HI.Name = "(lambda)";
HI.Kind = index::SymbolKind::Class;
}},
// auto on template instantiation
Index: clang-tools-extra/clangd/AST.cpp
===================================================================
--- clang-tools-extra/clangd/AST.cpp
+++ clang-tools-extra/clangd/AST.cpp
@@ -223,8 +223,11 @@
// Come up with a presentation for an anonymous entity.
if (isa<NamespaceDecl>(ND))
return "(anonymous namespace)";
- if (auto *Cls = llvm::dyn_cast<RecordDecl>(&ND))
+ if (auto *Cls = llvm::dyn_cast<RecordDecl>(&ND)) {
+ if (Cls->isLambda())
+ return "(lambda)";
return ("(anonymous " + Cls->getKindName() + ")").str();
+ }
if (isa<EnumDecl>(ND))
return "(anonymous enum)";
return "(anonymous)";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71544.234042.patch
Type: text/x-patch
Size: 1184 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191216/db81d668/attachment.bin>
More information about the cfe-commits
mailing list