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