1
1
use std:: borrow:: Cow ;
2
2
3
3
use rustc_codegen_ssa:: debuginfo:: type_names:: { compute_debuginfo_type_name, cpp_like_debuginfo} ;
4
- use rustc_codegen_ssa:: debuginfo:: wants_c_like_enum_debuginfo;
4
+ use rustc_codegen_ssa:: debuginfo:: { tag_base_type , wants_c_like_enum_debuginfo} ;
5
5
use rustc_hir:: def:: CtorKind ;
6
6
use rustc_index:: IndexSlice ;
7
7
use rustc_middle:: bug;
8
8
use rustc_middle:: mir:: CoroutineLayout ;
9
- use rustc_middle:: ty:: layout:: { IntegerExt , LayoutOf , PrimitiveExt , TyAndLayout } ;
9
+ use rustc_middle:: ty:: layout:: { LayoutOf , TyAndLayout } ;
10
10
use rustc_middle:: ty:: { self , AdtDef , CoroutineArgs , CoroutineArgsExt , Ty , VariantDef } ;
11
11
use rustc_span:: Symbol ;
12
- use rustc_target:: abi:: {
13
- FieldIdx , HasDataLayout , Integer , Primitive , TagEncoding , VariantIdx , Variants ,
14
- } ;
12
+ use rustc_target:: abi:: { FieldIdx , TagEncoding , VariantIdx , Variants } ;
15
13
16
14
use super :: type_map:: { DINodeCreationResult , UniqueTypeId } ;
17
15
use super :: { size_and_align_of, SmallVec } ;
@@ -39,7 +37,7 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
39
37
40
38
let enum_type_and_layout = cx. layout_of ( enum_type) ;
41
39
42
- if wants_c_like_enum_debuginfo ( enum_type_and_layout) {
40
+ if wants_c_like_enum_debuginfo ( cx . tcx , enum_type_and_layout) {
43
41
return build_c_style_enum_di_node ( cx, enum_adt_def, enum_type_and_layout) ;
44
42
}
45
43
@@ -74,7 +72,7 @@ fn build_c_style_enum_di_node<'ll, 'tcx>(
74
72
di_node : build_enumeration_type_di_node (
75
73
cx,
76
74
& compute_debuginfo_type_name ( cx. tcx , enum_type_and_layout. ty , false ) ,
77
- tag_base_type ( cx, enum_type_and_layout) ,
75
+ tag_base_type ( cx. tcx , enum_type_and_layout) ,
78
76
enum_adt_def. discriminants ( cx. tcx ) . map ( |( variant_index, discr) | {
79
77
let name = Cow :: from ( enum_adt_def. variant ( variant_index) . name . as_str ( ) ) ;
80
78
( name, discr. val )
@@ -85,48 +83,6 @@ fn build_c_style_enum_di_node<'ll, 'tcx>(
85
83
}
86
84
}
87
85
88
- /// Extract the type with which we want to describe the tag of the given enum or coroutine.
89
- fn tag_base_type < ' ll , ' tcx > (
90
- cx : & CodegenCx < ' ll , ' tcx > ,
91
- enum_type_and_layout : TyAndLayout < ' tcx > ,
92
- ) -> Ty < ' tcx > {
93
- assert ! ( match enum_type_and_layout. ty. kind( ) {
94
- ty:: Coroutine ( ..) => true ,
95
- ty:: Adt ( adt_def, _) => adt_def. is_enum( ) ,
96
- _ => false ,
97
- } ) ;
98
-
99
- match enum_type_and_layout. layout . variants ( ) {
100
- // A single-variant enum has no discriminant.
101
- Variants :: Single { .. } => {
102
- bug ! ( "tag_base_type() called for enum without tag: {:?}" , enum_type_and_layout)
103
- }
104
-
105
- Variants :: Multiple { tag_encoding : TagEncoding :: Niche { .. } , tag, .. } => {
106
- // Niche tags are always normalized to unsized integers of the correct size.
107
- match tag. primitive ( ) {
108
- Primitive :: Int ( t, _) => t,
109
- Primitive :: Float ( f) => Integer :: from_size ( f. size ( ) ) . unwrap ( ) ,
110
- // FIXME(erikdesjardins): handle non-default addrspace ptr sizes
111
- Primitive :: Pointer ( _) => {
112
- // If the niche is the NULL value of a reference, then `discr_enum_ty` will be
113
- // a RawPtr. CodeView doesn't know what to do with enums whose base type is a
114
- // pointer so we fix this up to just be `usize`.
115
- // DWARF might be able to deal with this but with an integer type we are on
116
- // the safe side there too.
117
- cx. data_layout ( ) . ptr_sized_integer ( )
118
- }
119
- }
120
- . to_ty ( cx. tcx , false )
121
- }
122
-
123
- Variants :: Multiple { tag_encoding : TagEncoding :: Direct , tag, .. } => {
124
- // Direct tags preserve the sign.
125
- tag. primitive ( ) . to_ty ( cx. tcx )
126
- }
127
- }
128
- }
129
-
130
86
/// Build a DW_TAG_enumeration_type debuginfo node, with the given base type and variants.
131
87
/// This is a helper function and does not register anything in the type map by itself.
132
88
///
0 commit comments