[PATCH] D42082: Add DWARF for discriminated unions

Tom Tromey via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 18 10:33:05 PST 2018


tromey added a comment.

> Well, you'll want an actual enumeration_type for the type of the struct's field, and if enums don't otherwise occur naturally in Rust, that seems like a pretty good indication all by itself.

A data-less Rust enum is represented in a more C-like way.  That is, something like:

  enum JustSomeValues { A, B, C }

This turns into `DW_TAG_enumeration_type`.

I don't plan to have rustc emit an enumeration type for the discriminant.  This is done presently, but IME is more work for debuggers -- it has to be mostly ignored because it doesn't correspond to any actual language feature -- and with the variant approach it is also unneeded.  So, this is removed in my patches.

> Adding a TAG_variant_part that had no children could also work, although it seems a little odd and might trip up an unwary non-Rust-aware debugger.

I was thinking perhaps a variant part with a single child but no discriminant.  The case in question here is something like

  enum Univariant { TheSoleVariant(u8) }

If we're concerned about non-Rust-aware debuggers, or the wrath of the Sony person, then a new tag would be a better choice.


Repository:
  rL LLVM

https://reviews.llvm.org/D42082





More information about the llvm-commits mailing list