Generate better debuginfo for directly tagged enums

This commit is contained in:
Wesley Wiser 2021-04-26 14:39:57 -04:00
parent 1e13a9bb33
commit f353cbf1a1
5 changed files with 52 additions and 22 deletions

View file

@ -1574,7 +1574,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
MemberDescription {
name: if fallback {
String::new()
format!("Variant{}", i.as_u32())
} else {
variant_info.variant_name()
},
@ -1886,8 +1886,9 @@ fn describe_enum_variant(
// We have the layout of an enum variant, we need the layout of the outer enum
let enum_layout = cx.layout_of(layout.ty);
let offset = enum_layout.fields.offset(tag_field.as_usize());
let tag_name = if cx.tcx.sess.target.is_like_msvc { "variant$" } else { "RUST$ENUM$DISR" };
let args =
("RUST$ENUM$DISR".to_owned(), enum_layout.field(cx, tag_field.as_usize()).ty);
(tag_name.to_owned(), enum_layout.field(cx, tag_field.as_usize()).ty);
(Some(offset), Some(args))
}
_ => (None, None),
@ -2062,7 +2063,7 @@ fn prepare_enum_metadata(
unsafe {
llvm::LLVMRustDIBuilderCreateUnionType(
DIB(cx),
containing_scope,
None,
enum_name.as_ptr().cast(),
enum_name.len(),
file_metadata,
@ -2437,7 +2438,7 @@ fn create_union_stub(
llvm::LLVMRustDIBuilderCreateUnionType(
DIB(cx),
containing_scope,
Some(containing_scope),
union_type_name.as_ptr().cast(),
union_type_name.len(),
unknown_file_metadata(cx),

View file

@ -2038,7 +2038,7 @@ extern "C" {
pub fn LLVMRustDIBuilderCreateUnionType(
Builder: &DIBuilder<'a>,
Scope: &'a DIScope,
Scope: Option<&'a DIScope>,
Name: *const c_char,
NameLen: size_t,
File: &'a DIFile,