# Function rustc_codegen_llvm::debuginfo::metadata::enums::native::build_enum_variant_member_di_node

source ·

    fn build_enum_variant_member_di_node<'ll, 'tcx>(
        cx: &CodegenCx<'ll, 'tcx>,
        enum_type_and_layout: TyAndLayout<'tcx>,
        variant_part_di_node: &'ll DIType,
        variant_member_info: &VariantMemberInfo<'_, 'll>
    ) -> &'ll DIType

Expand description

Build the debuginfo node for `DW_TAG_variant`:

          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)

This node looks like:

    DW_TAG_variant
      DW_AT_discr_value           0
      DW_TAG_member
        DW_AT_name                  None
        DW_AT_type                  <0x000002a1>
        DW_AT_alignment             0x00000002
        DW_AT_data_member_location  0

The DW_AT_discr_value is optional, and is omitted if

- This is the only variant of a univariant enum (i.e. their is no discriminant)
- This is the “untagged” variant of a niche-layout enum (where only the other variants are identified by a single value)

There is only ever a single member, the type of which is a struct that describes the fields of the variant (excluding the discriminant). The name of the member is the name of the variant as given in the source code. The DW_AT_data_member_location is always zero.

Note that the LLVM DIBuilder API is a bit unintuitive here. The DW_TAG_variant subtree (including the DW_TAG_member) is built by a single call to `LLVMRustDIBuilderCreateVariantMemberType()`.