@@ -11,7 +11,7 @@ use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
11
11
use rustc_middle:: ty:: { self , AdtDef , CoroutineArgs , CoroutineArgsExt , Ty } ;
12
12
use smallvec:: smallvec;
13
13
14
- use crate :: common:: { AsCCharPtr , CodegenCx } ;
14
+ use crate :: common:: CodegenCx ;
15
15
use crate :: debuginfo:: dwarf_const:: DW_TAG_const_type ;
16
16
use crate :: debuginfo:: metadata:: enums:: DiscrResult ;
17
17
use crate :: debuginfo:: metadata:: type_map:: { self , Stub , UniqueTypeId } ;
@@ -378,20 +378,17 @@ fn build_single_variant_union_fields<'ll, 'tcx>(
378
378
variant_struct_type_wrapper_di_node,
379
379
None ,
380
380
) ,
381
- unsafe {
382
- llvm:: LLVMRustDIBuilderCreateStaticMemberType (
383
- DIB ( cx) ,
384
- enum_type_di_node,
385
- TAG_FIELD_NAME . as_c_char_ptr( ) ,
386
- TAG_FIELD_NAME . len( ) ,
387
- unknown_file_metadata( cx) ,
388
- UNKNOWN_LINE_NUMBER ,
389
- variant_names_type_di_node,
390
- visibility_flags,
391
- Some ( cx. const_u64( SINGLE_VARIANT_VIRTUAL_DISR ) ) ,
392
- tag_base_type_align. bits( ) as u32 ,
393
- )
394
- }
381
+ create_static_member_type(
382
+ cx,
383
+ enum_type_di_node,
384
+ TAG_FIELD_NAME ,
385
+ unknown_file_metadata( cx) ,
386
+ UNKNOWN_LINE_NUMBER ,
387
+ variant_names_type_di_node,
388
+ visibility_flags,
389
+ Some ( cx. const_u64( SINGLE_VARIANT_VIRTUAL_DISR ) ) ,
390
+ tag_base_type_align,
391
+ ) ,
395
392
]
396
393
}
397
394
@@ -576,21 +573,20 @@ fn build_variant_struct_wrapper_type_di_node<'ll, 'tcx>(
576
573
// directly inspected via the debugger visualizer - which compares it to the `tag` value
577
574
// (whose type is not modified at all) it shouldn't cause any real problems.
578
575
let ( t_di, align) = if name == ASSOC_CONST_DISCR_NAME {
579
- ( type_di_node_, align. bits ( ) as u32 )
576
+ ( type_di_node_, align)
580
577
} else {
581
578
let ty_u64 = Ty :: new_uint ( cx. tcx , ty:: UintTy :: U64 ) ;
582
- ( type_di_node ( cx, ty_u64) , Align :: EIGHT . bits ( ) as u32 )
579
+ ( type_di_node ( cx, ty_u64) , Align :: EIGHT )
583
580
} ;
584
581
585
582
// must wrap type in a `const` modifier for LLDB to be able to inspect the value of the member
586
583
let field_type =
587
584
llvm:: LLVMRustDIBuilderCreateQualifiedType ( DIB ( cx) , DW_TAG_const_type , t_di) ;
588
585
589
- llvm :: LLVMRustDIBuilderCreateStaticMemberType (
590
- DIB ( cx ) ,
586
+ create_static_member_type (
587
+ cx ,
591
588
wrapper_struct_type_di_node,
592
- name. as_c_char_ptr ( ) ,
593
- name. len ( ) ,
589
+ name,
594
590
unknown_file_metadata ( cx) ,
595
591
UNKNOWN_LINE_NUMBER ,
596
592
field_type,
@@ -975,3 +971,30 @@ fn variant_struct_wrapper_type_name(variant_index: VariantIdx) -> Cow<'static, s
975
971
. map ( |& s| Cow :: from ( s) )
976
972
. unwrap_or_else ( || format ! ( "Variant{}" , variant_index. as_usize( ) ) . into ( ) )
977
973
}
974
+
975
+ fn create_static_member_type < ' ll > (
976
+ cx : & CodegenCx < ' ll , ' _ > ,
977
+ scope : & ' ll llvm:: Metadata ,
978
+ name : & str ,
979
+ file : & ' ll llvm:: Metadata ,
980
+ line_number : c_uint ,
981
+ ty : & ' ll llvm:: Metadata ,
982
+ flags : DIFlags ,
983
+ value : Option < & ' ll llvm:: Value > ,
984
+ align : Align ,
985
+ ) -> & ' ll llvm:: Metadata {
986
+ unsafe {
987
+ llvm:: LLVMDIBuilderCreateStaticMemberType (
988
+ DIB ( cx) ,
989
+ scope,
990
+ name. as_ptr ( ) ,
991
+ name. len ( ) ,
992
+ file,
993
+ line_number,
994
+ ty,
995
+ flags,
996
+ value,
997
+ align. bits ( ) as c_uint ,
998
+ )
999
+ }
1000
+ }
0 commit comments