@@ -13,10 +13,9 @@ use super::metadata::file_metadata;
13
13
use super :: utils:: { DIB , span_start} ;
14
14
15
15
use llvm;
16
- use llvm:: debuginfo:: DIScope_opaque ;
16
+ use llvm:: debuginfo:: DIScope ;
17
17
use common:: CodegenCx ;
18
18
use rustc:: mir:: { Mir , SourceScope } ;
19
- use std:: ptr:: NonNull ;
20
19
21
20
use libc:: c_uint;
22
21
@@ -28,24 +27,24 @@ use rustc_data_structures::indexed_vec::{Idx, IndexVec};
28
27
use syntax_pos:: BytePos ;
29
28
30
29
#[ derive( Clone , Copy , Debug ) ]
31
- pub struct MirDebugScope {
32
- pub scope_metadata : Option < NonNull < DIScope_opaque > > ,
30
+ pub struct MirDebugScope < ' ll > {
31
+ pub scope_metadata : Option < & ' ll DIScope > ,
33
32
// Start and end offsets of the file to which this DIScope belongs.
34
33
// These are used to quickly determine whether some span refers to the same file.
35
34
pub file_start_pos : BytePos ,
36
35
pub file_end_pos : BytePos ,
37
36
}
38
37
39
- impl MirDebugScope {
38
+ impl MirDebugScope < ' ll > {
40
39
pub fn is_valid ( & self ) -> bool {
41
40
!self . scope_metadata . is_none ( )
42
41
}
43
42
}
44
43
45
44
/// Produce DIScope DIEs for each MIR Scope which has variables defined in it.
46
45
/// If debuginfo is disabled, the returned vector is empty.
47
- pub fn create_mir_scopes ( cx : & CodegenCx , mir : & Mir , debug_context : & FunctionDebugContext )
48
- -> IndexVec < SourceScope , MirDebugScope > {
46
+ pub fn create_mir_scopes ( cx : & CodegenCx < ' ll , ' _ > , mir : & Mir , debug_context : & FunctionDebugContext < ' ll > )
47
+ -> IndexVec < SourceScope , MirDebugScope < ' ll > > {
49
48
let null_scope = MirDebugScope {
50
49
scope_metadata : None ,
51
50
file_start_pos : BytePos ( 0 ) ,
@@ -77,12 +76,12 @@ pub fn create_mir_scopes(cx: &CodegenCx, mir: &Mir, debug_context: &FunctionDebu
77
76
scopes
78
77
}
79
78
80
- fn make_mir_scope ( cx : & CodegenCx ,
79
+ fn make_mir_scope ( cx : & CodegenCx < ' ll , ' _ > ,
81
80
mir : & Mir ,
82
81
has_variables : & BitVector < SourceScope > ,
83
- debug_context : & FunctionDebugContextData ,
82
+ debug_context : & FunctionDebugContextData < ' ll > ,
84
83
scope : SourceScope ,
85
- scopes : & mut IndexVec < SourceScope , MirDebugScope > ) {
84
+ scopes : & mut IndexVec < SourceScope , MirDebugScope < ' ll > > ) {
86
85
if scopes[ scope] . is_valid ( ) {
87
86
return ;
88
87
}
@@ -95,7 +94,7 @@ fn make_mir_scope(cx: &CodegenCx,
95
94
// The root is the function itself.
96
95
let loc = span_start ( cx, mir. span ) ;
97
96
scopes[ scope] = MirDebugScope {
98
- scope_metadata : NonNull :: new ( debug_context. fn_metadata ) ,
97
+ scope_metadata : Some ( debug_context. fn_metadata ) ,
99
98
file_start_pos : loc. file . start_pos ,
100
99
file_end_pos : loc. file . end_pos ,
101
100
} ;
@@ -109,7 +108,7 @@ fn make_mir_scope(cx: &CodegenCx,
109
108
// However, we don't skip creating a nested scope if
110
109
// our parent is the root, because we might want to
111
110
// put arguments in the root and not have shadowing.
112
- if parent_scope. scope_metadata . unwrap ( ) . as_ptr ( ) != debug_context. fn_metadata {
111
+ if parent_scope. scope_metadata . unwrap ( ) != debug_context. fn_metadata {
113
112
scopes[ scope] = parent_scope;
114
113
return ;
115
114
}
@@ -121,9 +120,9 @@ fn make_mir_scope(cx: &CodegenCx,
121
120
debug_context. defining_crate ) ;
122
121
123
122
let scope_metadata = unsafe {
124
- NonNull :: new ( llvm:: LLVMRustDIBuilderCreateLexicalBlock (
123
+ Some ( llvm:: LLVMRustDIBuilderCreateLexicalBlock (
125
124
DIB ( cx) ,
126
- parent_scope. scope_metadata . unwrap ( ) . as_ptr ( ) ,
125
+ parent_scope. scope_metadata . unwrap ( ) ,
127
126
file_metadata,
128
127
loc. line as c_uint ,
129
128
loc. col . to_usize ( ) as c_uint ) )
0 commit comments