@@ -18,7 +18,9 @@ use super::utils::{debug_context, DIB, span_start, bytes_to_bits, size_and_align
18
18
fn_should_be_ignored, is_node_local_to_unit} ;
19
19
use super :: namespace:: mangled_name_of_item;
20
20
use super :: type_names:: { compute_debuginfo_type_name, push_debuginfo_type_name} ;
21
- use super :: { declare_local, VariableKind , VariableAccess } ;
21
+ use super :: { declare_local, VariableKind , VariableAccess , CrateDebugContext } ;
22
+ use context:: SharedCrateContext ;
23
+ use session:: Session ;
22
24
23
25
use llvm:: { self , ValueRef } ;
24
26
use llvm:: debuginfo:: { DIType , DIFile , DIScope , DIDescriptor , DICompositeType } ;
@@ -48,7 +50,6 @@ use syntax::ast;
48
50
use syntax:: parse:: token;
49
51
use syntax_pos:: { self , Span } ;
50
52
51
-
52
53
// From DWARF 5.
53
54
// See http://www.dwarfstd.org/ShowIssue.php?issue=140129.1
54
55
const DW_LANG_RUST : c_uint = 0x1c ;
@@ -981,14 +982,17 @@ fn pointer_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
981
982
return ptr_metadata;
982
983
}
983
984
984
- pub fn compile_unit_metadata ( cx : & CrateContext ) -> DIDescriptor {
985
- let work_dir = & cx. sess ( ) . working_dir ;
986
- let compile_unit_name = match cx. sess ( ) . local_crate_source_file {
987
- None => fallback_path ( cx) ,
985
+ pub fn compile_unit_metadata ( scc : & SharedCrateContext ,
986
+ debug_context : & CrateDebugContext ,
987
+ sess : & Session )
988
+ -> DIDescriptor {
989
+ let work_dir = & sess. working_dir ;
990
+ let compile_unit_name = match sess. local_crate_source_file {
991
+ None => fallback_path ( scc) ,
988
992
Some ( ref abs_path) => {
989
993
if abs_path. is_relative ( ) {
990
- cx . sess ( ) . warn ( "debuginfo: Invalid path to crate's local root source file!" ) ;
991
- fallback_path ( cx )
994
+ sess. warn ( "debuginfo: Invalid path to crate's local root source file!" ) ;
995
+ fallback_path ( scc )
992
996
} else {
993
997
match abs_path. strip_prefix ( work_dir) {
994
998
Ok ( ref p) if p. is_relative ( ) => {
@@ -998,7 +1002,7 @@ pub fn compile_unit_metadata(cx: &CrateContext) -> DIDescriptor {
998
1002
path2cstr ( & Path :: new ( "." ) . join ( p) )
999
1003
}
1000
1004
}
1001
- _ => fallback_path ( cx )
1005
+ _ => fallback_path ( scc )
1002
1006
}
1003
1007
}
1004
1008
}
@@ -1015,19 +1019,19 @@ pub fn compile_unit_metadata(cx: &CrateContext) -> DIDescriptor {
1015
1019
let split_name = "\0 " ;
1016
1020
return unsafe {
1017
1021
llvm:: LLVMDIBuilderCreateCompileUnit (
1018
- debug_context ( cx ) . builder ,
1022
+ debug_context. builder ,
1019
1023
DW_LANG_RUST ,
1020
1024
compile_unit_name,
1021
1025
work_dir. as_ptr ( ) ,
1022
1026
producer. as_ptr ( ) ,
1023
- cx . sess ( ) . opts . optimize != config:: OptLevel :: No ,
1027
+ sess. opts . optimize != config:: OptLevel :: No ,
1024
1028
flags. as_ptr ( ) as * const _ ,
1025
1029
0 ,
1026
1030
split_name. as_ptr ( ) as * const _ )
1027
1031
} ;
1028
1032
1029
- fn fallback_path ( cx : & CrateContext ) -> CString {
1030
- CString :: new ( cx . link_meta ( ) . crate_name . clone ( ) ) . unwrap ( )
1033
+ fn fallback_path ( scc : & :: context :: SharedCrateContext ) -> CString {
1034
+ CString :: new ( scc . link_meta ( ) . crate_name . clone ( ) ) . unwrap ( )
1031
1035
}
1032
1036
}
1033
1037
0 commit comments