Add file and line metadata for enum variant and fields
This commit is contained in:
parent
af6b0deaf3
commit
aa485fc2a1
5 changed files with 27 additions and 19 deletions
|
@ -338,6 +338,7 @@ fn build_single_variant_union_fields<'ll, 'tcx>(
|
|||
|
||||
let variant_struct_type_wrapper_di_node = build_variant_struct_wrapper_type_di_node(
|
||||
cx,
|
||||
enum_adt_def,
|
||||
enum_type_and_layout,
|
||||
enum_type_di_node,
|
||||
variant_index,
|
||||
|
@ -470,6 +471,7 @@ fn build_variant_names_type_di_node<'ll, 'tcx>(
|
|||
|
||||
fn build_variant_struct_wrapper_type_di_node<'ll, 'tcx>(
|
||||
cx: &CodegenCx<'ll, 'tcx>,
|
||||
enum_adt_def: AdtDef<'tcx>,
|
||||
enum_or_coroutine_type_and_layout: TyAndLayout<'tcx>,
|
||||
enum_or_coroutine_type_di_node: &'ll DIType,
|
||||
variant_index: VariantIdx,
|
||||
|
@ -491,7 +493,7 @@ fn build_variant_struct_wrapper_type_di_node<'ll, 'tcx>(
|
|||
variant_index,
|
||||
),
|
||||
&variant_struct_wrapper_type_name(variant_index),
|
||||
None,
|
||||
Some(enum_adt_def.variant(variant_index).def_id),
|
||||
// NOTE: We use size and align of enum_type, not from variant_layout:
|
||||
size_and_align_of(enum_or_coroutine_type_and_layout),
|
||||
Some(enum_or_coroutine_type_di_node),
|
||||
|
@ -778,8 +780,13 @@ fn build_union_fields_for_direct_tag_enum_or_coroutine<'ll, 'tcx>(
|
|||
let field_name = variant_union_field_name(variant_member_info.variant_index);
|
||||
let (size, align) = size_and_align_of(enum_type_and_layout);
|
||||
|
||||
let ty::Adt(enum_adt_def, _) = enum_type_and_layout.ty.kind() else {
|
||||
unreachable!();
|
||||
};
|
||||
|
||||
let variant_struct_type_wrapper = build_variant_struct_wrapper_type_di_node(
|
||||
cx,
|
||||
*enum_adt_def,
|
||||
enum_type_and_layout,
|
||||
enum_type_di_node,
|
||||
variant_member_info.variant_index,
|
||||
|
|
|
@ -208,7 +208,7 @@ fn build_enum_variant_struct_type_di_node<'ll, 'tcx>(
|
|||
variant_index,
|
||||
),
|
||||
variant_def.name.as_str(),
|
||||
None,
|
||||
Some(variant_def.def_id),
|
||||
// NOTE: We use size and align of enum_type, not from variant_layout:
|
||||
size_and_align_of(enum_type_and_layout),
|
||||
Some(enum_type_di_node),
|
||||
|
|
|
@ -14,7 +14,8 @@ use crate::common::{AsCCharPtr, CodegenCx};
|
|||
use crate::debuginfo::metadata::type_map::{self, Stub, StubInfo, UniqueTypeId};
|
||||
use crate::debuginfo::metadata::{
|
||||
DINodeCreationResult, NO_GENERICS, SmallVec, UNKNOWN_LINE_NUMBER, file_metadata,
|
||||
size_and_align_of, type_di_node, unknown_file_metadata, visibility_di_flags,
|
||||
file_metadata_from_def_id, size_and_align_of, type_di_node, unknown_file_metadata,
|
||||
visibility_di_flags,
|
||||
};
|
||||
use crate::debuginfo::utils::{DIB, create_DIArray, get_namespace_for_item};
|
||||
use crate::llvm::debuginfo::{DIFile, DIFlags, DIType};
|
||||
|
@ -85,7 +86,10 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
|
|||
enum_type_and_layout.for_variant(cx, variant_index),
|
||||
visibility_flags,
|
||||
),
|
||||
source_info: None,
|
||||
source_info: Some(file_metadata_from_def_id(
|
||||
cx,
|
||||
Some(enum_adt_def.variant(variant_index).def_id),
|
||||
)),
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
@ -93,6 +97,7 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
|
|||
cx,
|
||||
enum_type_and_layout,
|
||||
enum_type_di_node,
|
||||
enum_adt_def.did(),
|
||||
&variant_member_infos[..],
|
||||
)]
|
||||
},
|
||||
|
@ -203,6 +208,7 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>(
|
|||
cx,
|
||||
coroutine_type_and_layout,
|
||||
coroutine_type_di_node,
|
||||
coroutine_def_id,
|
||||
&variant_struct_type_di_nodes[..],
|
||||
)]
|
||||
},
|
||||
|
@ -230,6 +236,7 @@ fn build_enum_variant_part_di_node<'ll, 'tcx>(
|
|||
cx: &CodegenCx<'ll, 'tcx>,
|
||||
enum_type_and_layout: TyAndLayout<'tcx>,
|
||||
enum_type_di_node: &'ll DIType,
|
||||
enum_type_def_id: rustc_span::def_id::DefId,
|
||||
variant_member_infos: &[VariantMemberInfo<'_, 'll>],
|
||||
) -> &'ll DIType {
|
||||
let tag_member_di_node =
|
||||
|
@ -238,6 +245,8 @@ fn build_enum_variant_part_di_node<'ll, 'tcx>(
|
|||
let variant_part_unique_type_id =
|
||||
UniqueTypeId::for_enum_variant_part(cx.tcx, enum_type_and_layout.ty);
|
||||
|
||||
let (file_metadata, line_number) = file_metadata_from_def_id(cx, Some(enum_type_def_id));
|
||||
|
||||
let stub = StubInfo::new(
|
||||
cx,
|
||||
variant_part_unique_type_id,
|
||||
|
@ -248,8 +257,8 @@ fn build_enum_variant_part_di_node<'ll, 'tcx>(
|
|||
enum_type_di_node,
|
||||
variant_part_name.as_c_char_ptr(),
|
||||
variant_part_name.len(),
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
file_metadata,
|
||||
line_number,
|
||||
enum_type_and_layout.size.bits(),
|
||||
enum_type_and_layout.align.abi.bits() as u32,
|
||||
DIFlags::FlagZero,
|
||||
|
|
|
@ -182,17 +182,7 @@ pub(super) fn stub<'ll, 'tcx>(
|
|||
let empty_array = create_DIArray(DIB(cx), &[]);
|
||||
let unique_type_id_str = unique_type_id.generate_unique_id_string(cx.tcx);
|
||||
|
||||
let (file_metadata, line_number) = if let Some(def_id) = def_id {
|
||||
let span = cx.tcx.def_span(def_id);
|
||||
if !span.is_dummy() {
|
||||
let loc = cx.lookup_debug_loc(span.lo());
|
||||
(file_metadata(cx, &loc.file), loc.line)
|
||||
} else {
|
||||
(unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER)
|
||||
}
|
||||
} else {
|
||||
(unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER)
|
||||
};
|
||||
let (file_metadata, line_number) = super::file_metadata_from_def_id(cx, def_id);
|
||||
|
||||
let metadata = match kind {
|
||||
Stub::Struct | Stub::VTableTy { .. } => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue