[RFA,2/2] Set TYPE_NAME for Rust unions
Commit Message
I noticed that read_structure_type sets TYPE_NAME to TYPE_TAG_NAME for
some things, but not for unions. For Rust, I think we want to do this
for all types, so this patch adds the needed code.
I think that TYPE_TAG_NAME is confusing and should probably be
removed. I am working on a patch to do this, but in the meantime this
seemed like a reasonable change to apply. I suspect this change would
be ok for C++ as well, but I do not know about D.
2018-04-12 Tom Tromey <tom@tromey.com>
* dwarf2read.c (read_structure_type): Set TYPE_NAME for rust
unions.
---
gdb/ChangeLog | 5 +++++
gdb/dwarf2read.c | 4 +++-
2 files changed, 8 insertions(+), 1 deletion(-)
Comments
> I think that TYPE_TAG_NAME is confusing and should probably be
> removed. I am working on a patch to do this, but in the meantime this
> seemed like a reasonable change to apply. I suspect this change would
> be ok for C++ as well, but I do not know about D.
I agree that TYPE_TAG_NAME is confusing, and I would welcome it being
removed.
> 2018-04-12 Tom Tromey <tom@tromey.com>
>
> * dwarf2read.c (read_structure_type): Set TYPE_NAME for rust
> unions.
The patch looks good to me, but I'd like to see if others have comments
about C++. I'm trying to remember if C++ enums might have different
rules compared to C enums, and I'm not remembering any... If there
weren't any difference, and things were OK with C enums, one might
think that we're OK for C++ enums as well...
No way to test this either?
>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:
>> 2018-04-12 Tom Tromey <tom@tromey.com>
>>
>> * dwarf2read.c (read_structure_type): Set TYPE_NAME for rust
>> unions.
Joel> The patch looks good to me, but I'd like to see if others have comments
Joel> about C++. I'm trying to remember if C++ enums might have different
Joel> rules compared to C enums, and I'm not remembering any... If there
Joel> weren't any difference, and things were OK with C enums, one might
Joel> think that we're OK for C++ enums as well...
Joel> No way to test this either?
I am not sure. However, my TYPE_TAG_NAME deletion patch is ready now
(I'll send it momentarily), so I think we can just drop this one,
because that patch obsoletes it.
Tom
@@ -1,5 +1,10 @@
2018-04-12 Tom Tromey <tom@tromey.com>
+ * dwarf2read.c (read_structure_type): Set TYPE_NAME for rust
+ unions.
+
+2018-04-12 Tom Tromey <tom@tromey.com>
+
* dwarf2read.c (quirk_rust_enum): Conditionally drop the
discriminant field.
@@ -15631,7 +15631,9 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
TYPE_TAG_NAME (type) = full_name;
if (die->tag == DW_TAG_structure_type
- || die->tag == DW_TAG_class_type)
+ || die->tag == DW_TAG_class_type
+ || (cu->language == language_rust
+ && die->tag == DW_TAG_union_type))
TYPE_NAME (type) = TYPE_TAG_NAME (type);
}
else