8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
- use super :: FunctionDebugContext ;
11
+ use super :: { FunctionDebugContext , FunctionDebugContextData } ;
12
12
use super :: metadata:: file_metadata;
13
13
use super :: utils:: { DIB , span_start} ;
14
14
15
15
use llvm;
16
- use llvm:: debuginfo:: { DIScope , DISubprogram } ;
16
+ use llvm:: debuginfo:: DIScope ;
17
17
use common:: CrateContext ;
18
18
use rustc:: mir:: { Mir , VisibilityScope } ;
19
19
@@ -53,8 +53,8 @@ pub fn create_mir_scopes(ccx: &CrateContext, mir: &Mir, debug_context: &Function
53
53
} ;
54
54
let mut scopes = IndexVec :: from_elem ( null_scope, & mir. visibility_scopes ) ;
55
55
56
- let fn_metadata = match * debug_context {
57
- FunctionDebugContext :: RegularContext ( ref data) => data. fn_metadata ,
56
+ let debug_context = match * debug_context {
57
+ FunctionDebugContext :: RegularContext ( ref data) => data,
58
58
FunctionDebugContext :: DebugInfoDisabled |
59
59
FunctionDebugContext :: FunctionWithoutDebugInfo => {
60
60
return scopes;
@@ -71,7 +71,7 @@ pub fn create_mir_scopes(ccx: &CrateContext, mir: &Mir, debug_context: &Function
71
71
// Instantiate all scopes.
72
72
for idx in 0 ..mir. visibility_scopes . len ( ) {
73
73
let scope = VisibilityScope :: new ( idx) ;
74
- make_mir_scope ( ccx, & mir, & has_variables, fn_metadata , scope, & mut scopes) ;
74
+ make_mir_scope ( ccx, & mir, & has_variables, debug_context , scope, & mut scopes) ;
75
75
}
76
76
77
77
scopes
@@ -80,7 +80,7 @@ pub fn create_mir_scopes(ccx: &CrateContext, mir: &Mir, debug_context: &Function
80
80
fn make_mir_scope ( ccx : & CrateContext ,
81
81
mir : & Mir ,
82
82
has_variables : & BitVector ,
83
- fn_metadata : DISubprogram ,
83
+ debug_context : & FunctionDebugContextData ,
84
84
scope : VisibilityScope ,
85
85
scopes : & mut IndexVec < VisibilityScope , MirDebugScope > ) {
86
86
if scopes[ scope] . is_valid ( ) {
@@ -89,13 +89,13 @@ fn make_mir_scope(ccx: &CrateContext,
89
89
90
90
let scope_data = & mir. visibility_scopes [ scope] ;
91
91
let parent_scope = if let Some ( parent) = scope_data. parent_scope {
92
- make_mir_scope ( ccx, mir, has_variables, fn_metadata , parent, scopes) ;
92
+ make_mir_scope ( ccx, mir, has_variables, debug_context , parent, scopes) ;
93
93
scopes[ parent]
94
94
} else {
95
95
// The root is the function itself.
96
96
let loc = span_start ( ccx, mir. span ) ;
97
97
scopes[ scope] = MirDebugScope {
98
- scope_metadata : fn_metadata,
98
+ scope_metadata : debug_context . fn_metadata ,
99
99
file_start_pos : loc. file . start_pos ,
100
100
file_end_pos : loc. file . end_pos ,
101
101
} ;
@@ -109,14 +109,17 @@ fn make_mir_scope(ccx: &CrateContext,
109
109
// However, we don't skip creating a nested scope if
110
110
// our parent is the root, because we might want to
111
111
// put arguments in the root and not have shadowing.
112
- if parent_scope. scope_metadata != fn_metadata {
112
+ if parent_scope. scope_metadata != debug_context . fn_metadata {
113
113
scopes[ scope] = parent_scope;
114
114
return ;
115
115
}
116
116
}
117
117
118
118
let loc = span_start ( ccx, scope_data. span ) ;
119
- let file_metadata = file_metadata ( ccx, & loc. file . name , & loc. file . abs_path ) ;
119
+ let file_metadata = file_metadata ( ccx,
120
+ & loc. file . name ,
121
+ debug_context. defining_crate ) ;
122
+
120
123
let scope_metadata = unsafe {
121
124
llvm:: LLVMRustDIBuilderCreateLexicalBlock (
122
125
DIB ( ccx) ,
0 commit comments