[PATCH] D70209: [clangd] Expose value of enumerators to Hover API. (not UI yet)
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 14 08:34:44 PST 2019
This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.
Closed by commit rG37abeed8145b: [clangd] Expose value of enumerators to Hover API. (not UI yet) (authored by sammccall).
Changed prior to commit:
https://reviews.llvm.org/D70209?vs=229191&id=229318#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D70209/new/
https://reviews.llvm.org/D70209
Files:
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -981,6 +981,19 @@
HI.NamespaceScope = "";
HI.Value = "3";
}},
+ {R"cpp(
+ enum Color { RED, GREEN, };
+ Color x = [[GR^EEN]];
+ )cpp",
+ [](HoverInfo &HI) {
+ HI.Name = "GREEN";
+ HI.NamespaceScope = "";
+ HI.LocalScope = "Color::";
+ HI.Definition = "GREEN";
+ HI.Kind = SymbolKind::EnumMember;
+ HI.Type = "enum Color";
+ HI.Value = "1";
+ }},
// FIXME: We should use the Decl referenced, even if it comes from an
// implicit instantiation.
{R"cpp(
Index: clang-tools-extra/clangd/XRefs.cpp
===================================================================
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -657,6 +657,10 @@
Init->getType());
}
}
+ } else if (const auto *ECD = dyn_cast<EnumConstantDecl>(D)) {
+ // Dependent enums (e.g. nested in template classes) don't have values yet.
+ if (!ECD->getType()->isDependentType())
+ HI.Value = ECD->getInitVal().toString(10);
}
HI.Definition = printDefinition(D);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70209.229318.patch
Type: text/x-patch
Size: 1391 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191114/56511395/attachment-0001.bin>
More information about the cfe-commits
mailing list