================
@@ -875,7 +875,41 @@ void TextNodeDumper::dumpBareDeclRef(const Decl *D) {
 
   if (const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
     ColorScope Color(OS, ShowColors, DeclNameColor);
-    OS << " '" << ND->getDeclName() << '\'';
+    if (DeclarationName Name = ND->getDeclName())
+      OS << " '" << Name << '\'';
+    else
+      switch (ND->getKind()) {
+      case Decl::Decomposition: {
+        auto *DD = cast<DecompositionDecl>(ND);
+        OS << " first_binding '" << DD->bindings()[0]->getDeclName() << '\'';
+        break;
+      }
+      case Decl::Field: {
+        auto *FD = cast<FieldDecl>(ND);
+        OS << " index " << FD->getFieldIndex();
----------------
erichkeane wrote:

> It is at least a uniquely identifying property for the field within its 
> parent declaration.
> 
> We could call it `field_index`, but since this is a field and there is only 
> this index, it doesn't feel particularly confusing to me, otherwise do you 
> mean confusing when quickly skimming over the AST dump?

Yeah, exactly that.  `field_index` or `field at offset X`, or `field at index 
X` could be more readable?  It just isn't immediately clear what `index` for a 
field is relevant in the context of reading the AST (as this is actually more 
of a property of the containing struct instead of the field, but stored in the 
field itself for obvious reasons).

https://github.com/llvm/llvm-project/pull/124605
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to