[clang] [clang-tools-extra] [clangd] Show struct fields and enum members in hovers (PR #89557)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 21 22:43:44 PDT 2024


================
@@ -474,6 +477,17 @@ void DeclPrinter::VisitDeclContext(DeclContext *DC, bool Indent) {
   for (DeclContext::decl_iterator D = DC->decls_begin(), DEnd = DC->decls_end();
        D != DEnd; ++D) {
 
+    // Print enum members and public struct fields when
+    // PrintTagTypeContents=true. Only applicable when TerseOutput=true since
+    // otherwise all members are printed.
+    if (Policy.TerseOutput) {
+      assert(Policy.PrintTagTypeContents);
+      if (!(isa<EnumConstantDecl>(*D) ||
+            (isa<FieldDecl>(*D) &&
+             dyn_cast<FieldDecl>(*D)->getAccess() == AS_public)))
----------------
zyn0217 wrote:

Do you have any tests on C codes? Looking around the codebase, I think `AS_none` *might* be used in some cases wrt non-C++ codes?

https://github.com/llvm/llvm-project/pull/89557


More information about the cfe-commits mailing list