@@ -11,7 +11,7 @@ use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
1111use rustc_middle:: ty:: { self , AdtDef , CoroutineArgs , CoroutineArgsExt , Ty } ;
1212use smallvec:: smallvec;
1313
14- use crate :: common:: { AsCCharPtr , CodegenCx } ;
14+ use crate :: common:: CodegenCx ;
1515use crate :: debuginfo:: dwarf_const:: DW_TAG_const_type ;
1616use crate :: debuginfo:: metadata:: enums:: DiscrResult ;
1717use crate :: debuginfo:: metadata:: type_map:: { self , Stub , UniqueTypeId } ;
@@ -378,20 +378,17 @@ fn build_single_variant_union_fields<'ll, 'tcx>(
378378 variant_struct_type_wrapper_di_node,
379379 None ,
380380 ) ,
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+ ) ,
395392 ]
396393}
397394
@@ -576,21 +573,20 @@ fn build_variant_struct_wrapper_type_di_node<'ll, 'tcx>(
576573 // directly inspected via the debugger visualizer - which compares it to the `tag` value
577574 // (whose type is not modified at all) it shouldn't cause any real problems.
578575 let ( t_di, align) = if name == ASSOC_CONST_DISCR_NAME {
579- ( type_di_node_, align. bits ( ) as u32 )
576+ ( type_di_node_, align)
580577 } else {
581578 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 )
583580 } ;
584581
585582 // must wrap type in a `const` modifier for LLDB to be able to inspect the value of the member
586583 let field_type =
587584 llvm:: LLVMRustDIBuilderCreateQualifiedType ( DIB ( cx) , DW_TAG_const_type , t_di) ;
588585
589- llvm :: LLVMRustDIBuilderCreateStaticMemberType (
590- DIB ( cx ) ,
586+ create_static_member_type (
587+ cx ,
591588 wrapper_struct_type_di_node,
592- name. as_c_char_ptr ( ) ,
593- name. len ( ) ,
589+ name,
594590 unknown_file_metadata ( cx) ,
595591 UNKNOWN_LINE_NUMBER ,
596592 field_type,
@@ -975,3 +971,30 @@ fn variant_struct_wrapper_type_name(variant_index: VariantIdx) -> Cow<'static, s
975971 . map ( |& s| Cow :: from ( s) )
976972 . unwrap_or_else ( || format ! ( "Variant{}" , variant_index. as_usize( ) ) . into ( ) )
977973}
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