@@ -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
@@ -570,27 +567,28 @@ fn build_variant_struct_wrapper_type_di_node<'ll, 'tcx>(
570567 let build_assoc_const = |name : & str ,
571568 type_di_node_ : & ' ll DIType ,
572569 value : u64 ,
573- align : Align | unsafe {
570+ align : Align |
571+ -> & ' ll llvm:: Metadata {
574572 // FIXME: Currently we force all DISCR_* values to be u64's as LLDB seems to have
575573 // problems inspecting other value types. Since DISCR_* is typically only going to be
576574 // directly inspected via the debugger visualizer - which compares it to the `tag` value
577575 // (whose type is not modified at all) it shouldn't cause any real problems.
578576 let ( t_di, align) = if name == ASSOC_CONST_DISCR_NAME {
579- ( type_di_node_, align. bits ( ) as u32 )
577+ ( type_di_node_, align)
580578 } else {
581579 let ty_u64 = Ty :: new_uint ( cx. tcx , ty:: UintTy :: U64 ) ;
582- ( type_di_node ( cx, ty_u64) , Align :: EIGHT . bits ( ) as u32 )
580+ ( type_di_node ( cx, ty_u64) , Align :: EIGHT )
583581 } ;
584582
585583 // must wrap type in a `const` modifier for LLDB to be able to inspect the value of the member
586- let field_type =
587- llvm:: LLVMRustDIBuilderCreateQualifiedType ( DIB ( cx) , DW_TAG_const_type , t_di) ;
584+ let field_type = unsafe {
585+ llvm:: LLVMDIBuilderCreateQualifiedType ( DIB ( cx) , DW_TAG_const_type , t_di)
586+ } ;
588587
589- llvm :: LLVMRustDIBuilderCreateStaticMemberType (
590- DIB ( cx ) ,
588+ create_static_member_type (
589+ cx ,
591590 wrapper_struct_type_di_node,
592- name. as_c_char_ptr ( ) ,
593- name. len ( ) ,
591+ name,
594592 unknown_file_metadata ( cx) ,
595593 UNKNOWN_LINE_NUMBER ,
596594 field_type,
@@ -975,3 +973,30 @@ fn variant_struct_wrapper_type_name(variant_index: VariantIdx) -> Cow<'static, s
975973 . map ( |& s| Cow :: from ( s) )
976974 . unwrap_or_else ( || format ! ( "Variant{}" , variant_index. as_usize( ) ) . into ( ) )
977975}
976+
977+ fn create_static_member_type < ' ll > (
978+ cx : & CodegenCx < ' ll , ' _ > ,
979+ scope : & ' ll llvm:: Metadata ,
980+ name : & str ,
981+ file : & ' ll llvm:: Metadata ,
982+ line_number : c_uint ,
983+ ty : & ' ll llvm:: Metadata ,
984+ flags : DIFlags ,
985+ value : Option < & ' ll llvm:: Value > ,
986+ align : Align ,
987+ ) -> & ' ll llvm:: Metadata {
988+ unsafe {
989+ llvm:: LLVMDIBuilderCreateStaticMemberType (
990+ DIB ( cx) ,
991+ scope,
992+ name. as_ptr ( ) ,
993+ name. len ( ) ,
994+ file,
995+ line_number,
996+ ty,
997+ flags,
998+ value,
999+ align. bits ( ) as c_uint ,
1000+ )
1001+ }
1002+ }
0 commit comments