Require type_map::stub callers to supply file information
This change attaches file information (`DIFile` reference and line number) to struct debug info nodes. Before: ``` ; foo.ll ... !5 = !DIFile(filename: "<unknown>", directory: "") ... !16 = !DICompositeType(tag: DW_TAG_structure_type, name: "MyType", scope: !2, file: !5, size: 32, align: 32, elements: !17, templateParams: !19, identifier: "4cb373851db92e732c4cb5651b886dd0") ... ``` After: ``` ; foo.ll ... !3 = !DIFile(filename: "foo.rs", directory: "/home/matt/src/rust98678", checksumkind: CSK_SHA1, checksum: "bcb9f08512c8f3b8181ef4726012bc6807bc9be4") ... !16 = !DICompositeType(tag: DW_TAG_structure_type, name: "MyType", scope: !2, file: !3, line: 3, size: 32, align: 32, elements: !17, templateParams: !19, identifier: "9e5968c7af39c148acb253912b7f409f") ... ``` Fixes #98678
This commit is contained in:
@@ -204,6 +204,8 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
|
||||
Stub::Struct,
|
||||
unique_type_id,
|
||||
&ptr_type_debuginfo_name,
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
cx.size_and_align_of(ptr_type),
|
||||
NO_SCOPE_METADATA,
|
||||
DIFlags::FlagZero,
|
||||
@@ -371,6 +373,8 @@ fn build_dyn_type_di_node<'ll, 'tcx>(
|
||||
Stub::Struct,
|
||||
unique_type_id,
|
||||
&type_name,
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
cx.size_and_align_of(dyn_type),
|
||||
NO_SCOPE_METADATA,
|
||||
DIFlags::FlagZero,
|
||||
@@ -841,6 +845,8 @@ fn build_foreign_type_di_node<'ll, 'tcx>(
|
||||
Stub::Struct,
|
||||
unique_type_id,
|
||||
&compute_debuginfo_type_name(cx.tcx, t, false),
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
cx.size_and_align_of(t),
|
||||
Some(get_namespace_for_item(cx, def_id)),
|
||||
DIFlags::FlagZero,
|
||||
@@ -1044,6 +1050,15 @@ fn build_struct_type_di_node<'ll, 'tcx>(
|
||||
let struct_type_and_layout = cx.layout_of(struct_type);
|
||||
let variant_def = adt_def.non_enum_variant();
|
||||
|
||||
let tcx = cx.tcx;
|
||||
let struct_span = tcx.def_span(adt_def.did());
|
||||
let (file_metadata, line_number) = if !struct_span.is_dummy() {
|
||||
let loc = cx.lookup_debug_loc(struct_span.lo());
|
||||
(file_metadata(cx, &loc.file), loc.line)
|
||||
} else {
|
||||
(unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER)
|
||||
};
|
||||
|
||||
type_map::build_type_with_children(
|
||||
cx,
|
||||
type_map::stub(
|
||||
@@ -1051,6 +1066,8 @@ fn build_struct_type_di_node<'ll, 'tcx>(
|
||||
Stub::Struct,
|
||||
unique_type_id,
|
||||
&compute_debuginfo_type_name(cx.tcx, struct_type, false),
|
||||
file_metadata,
|
||||
line_number,
|
||||
size_and_align_of(struct_type_and_layout),
|
||||
Some(containing_scope),
|
||||
visibility_di_flags(cx, adt_def.did(), adt_def.did()),
|
||||
@@ -1154,6 +1171,8 @@ fn build_tuple_type_di_node<'ll, 'tcx>(
|
||||
Stub::Struct,
|
||||
unique_type_id,
|
||||
&type_name,
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
size_and_align_of(tuple_type_and_layout),
|
||||
NO_SCOPE_METADATA,
|
||||
DIFlags::FlagZero,
|
||||
@@ -1200,6 +1219,8 @@ fn build_closure_env_di_node<'ll, 'tcx>(
|
||||
Stub::Struct,
|
||||
unique_type_id,
|
||||
&type_name,
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
cx.size_and_align_of(closure_env_type),
|
||||
Some(containing_scope),
|
||||
DIFlags::FlagZero,
|
||||
@@ -1231,6 +1252,8 @@ fn build_union_type_di_node<'ll, 'tcx>(
|
||||
Stub::Union,
|
||||
unique_type_id,
|
||||
&type_name,
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
size_and_align_of(union_ty_and_layout),
|
||||
Some(containing_scope),
|
||||
DIFlags::FlagZero,
|
||||
@@ -1423,6 +1446,8 @@ fn build_vtable_type_di_node<'ll, 'tcx>(
|
||||
Stub::VTableTy { vtable_holder },
|
||||
unique_type_id,
|
||||
&vtable_type_name,
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
(size, pointer_align),
|
||||
NO_SCOPE_METADATA,
|
||||
DIFlags::FlagArtificial,
|
||||
|
||||
Reference in New Issue
Block a user