diff options
| author | Wesley Wiser <wesleywiser@microsoft.com> | 2021-05-26 12:02:07 -0400 |
|---|---|---|
| committer | Wesley Wiser <wesleywiser@microsoft.com> | 2021-06-02 10:23:12 -0400 |
| commit | 3127419e2b2cb4ad2e44a06d30af6a015daf4557 (patch) | |
| tree | 9a21fcf84ff04e4d747ae57ab26a6f13ba9ea945 /compiler/rustc_codegen_llvm/src/debuginfo | |
| parent | ef053fd6f0faa848097ff8b924ac859c667c8d15 (diff) | |
| download | rust-3127419e2b2cb4ad2e44a06d30af6a015daf4557.tar.gz rust-3127419e2b2cb4ad2e44a06d30af6a015daf4557.zip | |
Respond to review feedback
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/debuginfo')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs | 90 |
1 files changed, 28 insertions, 62 deletions
diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs index f56dace0d33..1e70664e64d 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs @@ -1485,8 +1485,8 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> { _ => bug!(), }; - // This will always find the metadata in the type map. let fallback = use_enum_fallback(cx); + // This will always find the metadata in the type map. let self_metadata = type_metadata(cx, self.enum_type, self.span); match self.layout.variants { @@ -1541,11 +1541,11 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> { // struct {variant 0 name} { // tag$ variant$; // <variant 0 fields> - // } Variant0; + // } variant0; // <other variant structs> // } // ``` - // The natvis in `intrinsic.nativs` then matches on `this.Variant0.variant$` to + // The natvis in `intrinsic.nativs` then matches on `this.variant0.variant$` to // determine which variant is active and then displays it. Some(DirectTag { tag_field: Field::from(tag_field), @@ -1582,7 +1582,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> { MemberDescription { name: if fallback { - format!("Variant{}", i.as_u32()) + format!("variant{}", i.as_u32()) } else { variant_info.variant_name() }, @@ -1623,43 +1623,27 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> { } }; - // For MSVC, we will generate a union of two structs, one for the dataful variant and one that just points to - // the discriminant field. We also create an enum that contains tag values for the non-dataful variants and - // make the discriminant field that type. We then use natvis to render the enum type correctly in Windbg/VS. + // For MSVC, we will generate a union of two fields, one for the dataful variant + // and one that just points to the discriminant. We also create an enum that + // contains tag values for the non-dataful variants and make the discriminant field + // that type. We then use natvis to render the enum type correctly in Windbg/VS. // This will generate debuginfo roughly equivalent to the following C: // ```c - // union enum$<{name}, {min niche}, {max niche}, {dataful variant name} { - // struct dataful_variant { + // union enum$<{name}, {min niche}, {max niche}, {dataful variant name}> { + // struct <dataful variant name> { // <fields in dataful variant> - // }, - // struct discriminant$ { - // enum tag$ { - // <non-dataful variants> - // } discriminant; - // } + // } dataful_variant; + // enum Discriminant$ { + // <non-dataful variants> + // } discriminant; // } // ``` // The natvis in `intrinsic.natvis` matches on the type name `enum$<*, *, *, *>` - // and evaluates `this.discriminant$.discriminant`. If the value is between - // the min niche and max niche, then the enum is in the dataful variant and - // `this.dataful_variant` is rendered. Otherwise, the enum is in one of the - // non-dataful variants. In that case, we just need to render the name of the - // `this.discriminant$.discriminant` enum. + // and evaluates `this.discriminant`. If the value is between the min niche and max + // niche, then the enum is in the dataful variant and `this.dataful_variant` is + // rendered. Otherwise, the enum is in one of the non-dataful variants. In that + // case, we just need to render the name of the `this.discriminant` enum. if fallback { - let unique_type_id = debug_context(cx) - .type_map - .borrow_mut() - .get_unique_type_id_of_enum_variant(cx, self.enum_type, "discriminant$"); - - let variant_metadata = create_struct_stub( - cx, - self.layout.ty, - &"discriminant$", - unique_type_id, - Some(self_metadata), - DIFlags::FlagArtificial, - ); - let dataful_variant_layout = self.layout.for_variant(cx, dataful_variant); let mut discr_enum_ty = tag.value.to_ty(cx.tcx); @@ -1694,8 +1678,8 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> { llvm::LLVMRustDIBuilderCreateEnumerationType( DIB(cx), self_metadata, - "tag$".as_ptr().cast(), - "tag$".len(), + "Discriminant$".as_ptr().cast(), + "Discriminant$".len(), unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER, tag.value.size(cx).bits(), @@ -1706,27 +1690,6 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> { ) }; - let (size, align) = - cx.size_and_align_of(dataful_variant_layout.field(cx, tag_field).ty); - let members = vec![MemberDescription { - name: "discriminant".to_string(), - type_metadata: discr_enum, - offset: dataful_variant_layout.fields.offset(tag_field), - size, - align, - flags: DIFlags::FlagArtificial, - discriminant: None, - source_info: None, - }]; - - set_members_of_composite_type( - cx, - self.enum_type, - variant_metadata, - members, - None, - ); - let variant_info = variant_info_for(dataful_variant); let (variant_type_metadata, member_desc_factory) = describe_enum_variant( cx, @@ -1747,6 +1710,9 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> { Some(&self.common_members), ); + let (size, align) = + cx.size_and_align_of(dataful_variant_layout.field(cx, tag_field).ty); + vec