@@ -2,7 +2,6 @@ use std::borrow::Cow;
2
2
use std:: fmt:: { self , Write } ;
3
3
use std:: hash:: { Hash , Hasher } ;
4
4
use std:: path:: { Path , PathBuf } ;
5
- use std:: sync:: Arc ;
6
5
use std:: { iter, ptr} ;
7
6
8
7
use libc:: { c_char, c_longlong, c_uint} ;
@@ -39,7 +38,7 @@ use crate::debuginfo::metadata::type_map::build_type_with_children;
39
38
use crate :: debuginfo:: utils:: { WidePtrKind , wide_pointer_kind} ;
40
39
use crate :: llvm;
41
40
use crate :: llvm:: debuginfo:: {
42
- DIBuilder , DICompositeType , DIDescriptor , DIFile , DIFlags , DILexicalBlock , DIScope , DIType ,
41
+ DICompositeType , DIDescriptor , DIFile , DIFlags , DILexicalBlock , DIScope , DIType ,
43
42
DebugEmissionKind , DebugNameTableKind ,
44
43
} ;
45
44
use crate :: value:: Value ;
@@ -624,38 +623,42 @@ pub(crate) fn file_metadata<'ll>(cx: &CodegenCx<'ll, '_>, source_file: &SourceFi
624
623
let source =
625
624
cx. sess ( ) . opts . unstable_opts . embed_source . then_some ( ( ) ) . and ( source_file. src . as_ref ( ) ) ;
626
625
627
- create_file ( DIB ( cx) , & file_name, & directory, & hash_value, hash_kind, source)
626
+ unsafe {
627
+ llvm:: LLVMRustDIBuilderCreateFile (
628
+ DIB ( cx) ,
629
+ file_name. as_c_char_ptr ( ) ,
630
+ file_name. len ( ) ,
631
+ directory. as_c_char_ptr ( ) ,
632
+ directory. len ( ) ,
633
+ hash_kind,
634
+ hash_value. as_c_char_ptr ( ) ,
635
+ hash_value. len ( ) ,
636
+ source. map_or ( ptr:: null ( ) , |x| x. as_c_char_ptr ( ) ) ,
637
+ source. map_or ( 0 , |x| x. len ( ) ) ,
638
+ )
639
+ }
628
640
}
629
641
}
630
642
631
643
fn unknown_file_metadata < ' ll > ( cx : & CodegenCx < ' ll , ' _ > ) -> & ' ll DIFile {
632
- debug_context ( cx) . created_files . borrow_mut ( ) . entry ( None ) . or_insert_with ( || {
633
- create_file ( DIB ( cx ) , "<unknown>" , "" , "" , llvm :: ChecksumKind :: None , None )
634
- } )
635
- }
644
+ debug_context ( cx) . created_files . borrow_mut ( ) . entry ( None ) . or_insert_with ( || unsafe {
645
+ let file_name = "<unknown>" ;
646
+ let directory = "" ;
647
+ let hash_value = "" ;
636
648
637
- fn create_file < ' ll > (
638
- builder : & DIBuilder < ' ll > ,
639
- file_name : & str ,
640
- directory : & str ,
641
- hash_value : & str ,
642
- hash_kind : llvm:: ChecksumKind ,
643
- source : Option < & Arc < String > > ,
644
- ) -> & ' ll DIFile {
645
- unsafe {
646
649
llvm:: LLVMRustDIBuilderCreateFile (
647
- builder ,
650
+ DIB ( cx ) ,
648
651
file_name. as_c_char_ptr ( ) ,
649
652
file_name. len ( ) ,
650
653
directory. as_c_char_ptr ( ) ,
651
654
directory. len ( ) ,
652
- hash_kind ,
655
+ llvm :: ChecksumKind :: None ,
653
656
hash_value. as_c_char_ptr ( ) ,
654
657
hash_value. len ( ) ,
655
- source . map_or ( ptr:: null ( ) , |x| x . as_c_char_ptr ( ) ) ,
656
- source . map_or ( 0 , |x| x . len ( ) ) ,
658
+ ptr:: null ( ) ,
659
+ 0 ,
657
660
)
658
- }
661
+ } )
659
662
}
660
663
661
664
trait MsvcBasicName {
@@ -930,13 +933,17 @@ pub(crate) fn build_compile_unit_di_node<'ll, 'tcx>(
930
933
} ;
931
934
932
935
unsafe {
933
- let compile_unit_file = create_file (
936
+ let compile_unit_file = llvm :: LLVMRustDIBuilderCreateFile (
934
937
debug_context. builder . as_ref ( ) ,
935
- & name_in_debuginfo,
936
- & work_dir,
937
- "" ,
938
+ name_in_debuginfo. as_c_char_ptr ( ) ,
939
+ name_in_debuginfo. len ( ) ,
940
+ work_dir. as_c_char_ptr ( ) ,
941
+ work_dir. len ( ) ,
938
942
llvm:: ChecksumKind :: None ,
939
- None ,
943
+ ptr:: null ( ) ,
944
+ 0 ,
945
+ ptr:: null ( ) ,
946
+ 0 ,
940
947
) ;
941
948
942
949
let unit_metadata = llvm:: LLVMRustDIBuilderCreateCompileUnit (
0 commit comments