Use the enum2$ Natvis visualiser for repr128 C-style enums

This commit is contained in:
beetrees
2024-07-21 16:52:04 +01:00
parent 80eb5a8e91
commit fe4fa2f1da
6 changed files with 136 additions and 67 deletions

View File

@@ -2,7 +2,7 @@ use std::borrow::Cow;
use libc::c_uint;
use rustc_codegen_ssa::debuginfo::type_names::compute_debuginfo_type_name;
use rustc_codegen_ssa::debuginfo::wants_c_like_enum_debuginfo;
use rustc_codegen_ssa::debuginfo::{tag_base_type, wants_c_like_enum_debuginfo};
use rustc_codegen_ssa::traits::ConstMethods;
use rustc_middle::bug;
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
@@ -11,7 +11,6 @@ use rustc_target::abi::{Size, TagEncoding, VariantIdx, Variants};
use smallvec::smallvec;
use crate::common::CodegenCx;
use crate::debuginfo::metadata::enums::tag_base_type;
use crate::debuginfo::metadata::type_map::{self, Stub, StubInfo, UniqueTypeId};
use crate::debuginfo::metadata::{
file_metadata, size_and_align_of, type_di_node, unknown_file_metadata, visibility_di_flags,
@@ -54,7 +53,7 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
let visibility_flags = visibility_di_flags(cx, enum_adt_def.did(), enum_adt_def.did());
assert!(!wants_c_like_enum_debuginfo(enum_type_and_layout));
assert!(!wants_c_like_enum_debuginfo(cx.tcx, enum_type_and_layout));
type_map::build_type_with_children(
cx,
@@ -131,7 +130,7 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>(
let containing_scope = get_namespace_for_item(cx, coroutine_def_id);
let coroutine_type_and_layout = cx.layout_of(coroutine_type);
assert!(!wants_c_like_enum_debuginfo(coroutine_type_and_layout));
assert!(!wants_c_like_enum_debuginfo(cx.tcx, coroutine_type_and_layout));
let coroutine_type_name = compute_debuginfo_type_name(cx.tcx, coroutine_type, false);
@@ -321,7 +320,7 @@ fn build_discr_member_di_node<'ll, 'tcx>(
&Variants::Single { .. } => None,
&Variants::Multiple { tag_field, .. } => {
let tag_base_type = tag_base_type(cx, enum_or_coroutine_type_and_layout);
let tag_base_type = tag_base_type(cx.tcx, enum_or_coroutine_type_and_layout);
let (size, align) = cx.size_and_align_of(tag_base_type);
unsafe {