@@ -39,8 +39,8 @@ use crate::debuginfo::metadata::type_map::build_type_with_children;
39
39
use crate :: debuginfo:: utils:: { WidePtrKind , wide_pointer_kind} ;
40
40
use crate :: llvm;
41
41
use crate :: llvm:: debuginfo:: {
42
- DIBuilder , DICompositeType , DIDescriptor , DIFile , DIFlags , DILexicalBlock , DIScope , DIType ,
43
- DebugEmissionKind , DebugNameTableKind ,
42
+ DIBasicType , DIBuilder , DICompositeType , DIDescriptor , DIFile , DIFlags , DILexicalBlock ,
43
+ DIScope , DIType , DebugEmissionKind , DebugNameTableKind ,
44
44
} ;
45
45
use crate :: value:: Value ;
46
46
@@ -491,26 +491,22 @@ pub(crate) fn type_di_node<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) ->
491
491
// FIXME(mw): Cache this via a regular UniqueTypeId instead of an extra field in the debug context.
492
492
fn recursion_marker_type_di_node < ' ll , ' tcx > ( cx : & CodegenCx < ' ll , ' tcx > ) -> & ' ll DIType {
493
493
* debug_context ( cx) . recursion_marker_type . get_or_init ( move || {
494
- unsafe {
495
- // The choice of type here is pretty arbitrary -
496
- // anything reading the debuginfo for a recursive
497
- // type is going to see *something* weird - the only
498
- // question is what exactly it will see.
499
- //
500
- // FIXME: the name `<recur_type>` does not fit the naming scheme
501
- // of other types.
502
- //
503
- // FIXME: it might make sense to use an actual pointer type here
504
- // so that debuggers can show the address.
505
- let name = "<recur_type>" ;
506
- llvm:: LLVMRustDIBuilderCreateBasicType (
507
- DIB ( cx) ,
508
- name. as_c_char_ptr ( ) ,
509
- name. len ( ) ,
510
- cx. tcx . data_layout . pointer_size . bits ( ) ,
511
- dwarf_const:: DW_ATE_unsigned ,
512
- )
513
- }
494
+ // The choice of type here is pretty arbitrary -
495
+ // anything reading the debuginfo for a recursive
496
+ // type is going to see *something* weird - the only
497
+ // question is what exactly it will see.
498
+ //
499
+ // FIXME: the name `<recur_type>` does not fit the naming scheme
500
+ // of other types.
501
+ //
502
+ // FIXME: it might make sense to use an actual pointer type here
503
+ // so that debuggers can show the address.
504
+ create_basic_type (
505
+ cx,
506
+ "<recur_type>" ,
507
+ cx. tcx . data_layout . pointer_size ,
508
+ dwarf_const:: DW_ATE_unsigned ,
509
+ )
514
510
} )
515
511
}
516
512
@@ -788,15 +784,7 @@ fn build_basic_type_di_node<'ll, 'tcx>(
788
784
_ => bug ! ( "debuginfo::build_basic_type_di_node - `t` is invalid type" ) ,
789
785
} ;
790
786
791
- let ty_di_node = unsafe {
792
- llvm:: LLVMRustDIBuilderCreateBasicType (
793
- DIB ( cx) ,
794
- name. as_c_char_ptr ( ) ,
795
- name. len ( ) ,
796
- cx. size_of ( t) . bits ( ) ,
797
- encoding,
798
- )
799
- } ;
787
+ let ty_di_node = create_basic_type ( cx, name, cx. size_of ( t) , encoding) ;
800
788
801
789
if !cpp_like_debuginfo {
802
790
return DINodeCreationResult :: new ( ty_di_node, false ) ;
@@ -824,6 +812,23 @@ fn build_basic_type_di_node<'ll, 'tcx>(
824
812
DINodeCreationResult :: new ( typedef_di_node, false )
825
813
}
826
814
815
+ fn create_basic_type < ' ll , ' tcx > (
816
+ cx : & CodegenCx < ' ll , ' tcx > ,
817
+ name : & str ,
818
+ size : Size ,
819
+ encoding : u32 ,
820
+ ) -> & ' ll DIBasicType {
821
+ unsafe {
822
+ llvm:: LLVMRustDIBuilderCreateBasicType (
823
+ DIB ( cx) ,
824
+ name. as_c_char_ptr ( ) ,
825
+ name. len ( ) ,
826
+ size. bits ( ) ,
827
+ encoding,
828
+ )
829
+ }
830
+ }
831
+
827
832
fn build_foreign_type_di_node < ' ll , ' tcx > (
828
833
cx : & CodegenCx < ' ll , ' tcx > ,
829
834
t : Ty < ' tcx > ,
0 commit comments