fn build_enum_variant_struct_type_di_node<'ll, 'tcx>(
    cx: &CodegenCx<'ll, 'tcx>,
    enum_type_and_layout: TyAndLayout<'tcx>,
    enum_type_di_node: &'ll DIType,
    variant_index: VariantIdx,
    variant_def: &VariantDef,
    variant_layout: TyAndLayout<'tcx>,
    di_flags: DIFlags,
) -> &'ll DIType
Expand description

Build the debuginfo node for the struct type describing a single variant of an enum.

      DW_TAG_structure_type              (top-level type for enum)
        DW_TAG_variant_part              (variant part)
          DW_AT_discr                    (reference to discriminant DW_TAG_member)
          DW_TAG_member                  (discriminant member)
          DW_TAG_variant                 (variant 1)
          DW_TAG_variant                 (variant 2)
          DW_TAG_variant                 (variant 3)
 --->   DW_TAG_structure_type            (type of variant 1)
 --->   DW_TAG_structure_type            (type of variant 2)
 --->   DW_TAG_structure_type            (type of variant 3)

In CPP-like mode, we have the exact same descriptions for each variant too:

      DW_TAG_union_type              (top-level type for enum)
        DW_TAG_member                    (member for variant 1)
        DW_TAG_member                    (member for variant 2)
        DW_TAG_member                    (member for variant 3)
 --->   DW_TAG_structure_type            (type of variant 1)
 --->   DW_TAG_structure_type            (type of variant 2)
 --->   DW_TAG_structure_type            (type of variant 3)
        DW_TAG_enumeration_type          (type of tag)

The node looks like:

DW_TAG_structure_type
  DW_AT_name                  <name-of-variant>
  DW_AT_byte_size             0x00000010
  DW_AT_alignment             0x00000008
  DW_TAG_member
    DW_AT_name                  <name-of-field-0>
    DW_AT_type                  <0x0000018e>
    DW_AT_alignment             0x00000004
    DW_AT_data_member_location  4
  DW_TAG_member
    DW_AT_name                  <name-of-field-1>
    DW_AT_type                  <0x00000195>
    DW_AT_alignment             0x00000008
    DW_AT_data_member_location  8
  ...

The type of a variant is always a struct type with the name of the variant and a DW_TAG_member for each field (but not the discriminant).