@@ -6,7 +6,7 @@ use std::{iter, ptr};
6
6
7
7
use libc:: { c_char, c_longlong, c_uint} ;
8
8
use rustc_abi:: { Align , Size } ;
9
- use rustc_codegen_ssa:: debuginfo:: type_names:: { cpp_like_debuginfo , VTableNameKind } ;
9
+ use rustc_codegen_ssa:: debuginfo:: type_names:: { VTableNameKind , cpp_like_debuginfo } ;
10
10
use rustc_codegen_ssa:: traits:: * ;
11
11
use rustc_hir:: def:: { CtorKind , DefKind } ;
12
12
use rustc_hir:: def_id:: { DefId , LOCAL_CRATE } ;
@@ -17,22 +17,22 @@ use rustc_middle::ty::{
17
17
} ;
18
18
use rustc_session:: config:: { self , DebugInfo , Lto } ;
19
19
use rustc_span:: symbol:: Symbol ;
20
- use rustc_span:: { hygiene , FileName , FileNameDisplayPreference , SourceFile , DUMMY_SP } ;
20
+ use rustc_span:: { DUMMY_SP , FileName , FileNameDisplayPreference , SourceFile , hygiene } ;
21
21
use rustc_symbol_mangling:: typeid_for_trait_ref;
22
22
use rustc_target:: spec:: DebuginfoKind ;
23
23
use smallvec:: smallvec;
24
24
use tracing:: { debug, instrument} ;
25
25
26
26
use self :: type_map:: { DINodeCreationResult , Stub , UniqueTypeId } ;
27
+ use super :: CodegenUnitDebugContext ;
27
28
use super :: namespace:: mangled_name_of_instance;
28
29
use super :: type_names:: { compute_debuginfo_type_name, compute_debuginfo_vtable_name} ;
29
30
use super :: utils:: {
30
- create_DIArray, debug_context, get_namespace_for_item, is_node_local_to_unit, DIB ,
31
+ DIB , create_DIArray, debug_context, get_namespace_for_item, is_node_local_to_unit,
31
32
} ;
32
- use super :: CodegenUnitDebugContext ;
33
33
use crate :: common:: { AsCCharPtr , CodegenCx } ;
34
34
use crate :: debuginfo:: metadata:: type_map:: build_type_with_children;
35
- use crate :: debuginfo:: utils:: { wide_pointer_kind , WidePtrKind } ;
35
+ use crate :: debuginfo:: utils:: { WidePtrKind , wide_pointer_kind } ;
36
36
use crate :: llvm:: debuginfo:: {
37
37
DIDescriptor , DIFile , DIFlags , DILexicalBlock , DIScope , DIType , DebugEmissionKind ,
38
38
DebugNameTableKind ,
@@ -191,49 +191,49 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
191
191
) ;
192
192
193
193
/*
194
- This block differentiates between mutable/immutable AND ref/ptr.
195
-
196
- References to references (&&T) are invalid constructs in C/C++, and we are piggybacking off
197
- of their type system when using LLDB (`TypeSystemClang`). Ptr-to-ref (*&T) and ref-to-ptr (&*T)
198
- are valid constructs though. That means we can tell the debugger that ref-to-ref's are actually
199
- ref-to-ptr's.
200
-
201
- Additionally, to help debugger visualizers differentiate ref-to-ref's that *look like* ref-to-ptr
202
- and *actual* ref-to-ptr, we can use the `rvalue_reference` tag. It's a C++ feature that doesn't
203
- quite have an equivalent in Rust, but *is* represented as `&&` which is perfect! That means
204
- ref-to-refs (&&T) will look like `T *&&` (i.e. an rvalue_reference to a pointer to T)
205
- and on the debugger visualizer end, the scripts can "undo" that translation.
206
-
207
- To handle immutable vs mutable (&/&mut) we use the `const` modifier. The modifier is applied
208
- with proper C/C++ rules (i.e. pointer-to-constant vs constant pointer). This means that an
209
- immutable reference applies the const modifier to the *pointee type*. When reversing the
210
- debuginfo translation, the `const` modifier doesn't describe the value it's applied to, it describes
211
- the pointer to the value. This is a **very** important distinction.
212
-
213
- Here are some examples, the Rust representation is on the left and the debuginfo translation on
214
- the right
215
-
216
- Cosnt vs Mut:
217
- *const T -> const T *
218
- *mut T -> T *
219
-
220
- *const *const T -> const T *const *
221
- *mut *mut T -> T **
222
-
223
- *mut *const T -> const T **
224
- *const *mut T -> T *const *
225
-
226
- Nested References:
227
- &T -> const T &
228
- &&T -> const T *const &&
229
- &&&T -> const T &const *const &&
230
- &&&&T -> const T *const &&const *const &&
231
-
232
- &mut T -> T &
233
- &mut &mut T -> T *&&
234
- &mut &mut &mut T -> T &*&&
235
- &mut &mut &mut &mut T -> T *&&*&&
236
- */
194
+ This block differentiates between mutable/immutable AND ref/ptr.
195
+
196
+ References to references (&&T) are invalid constructs in C/C++, and we are piggybacking off
197
+ of their type system when using LLDB (`TypeSystemClang`). Ptr-to-ref (*&T) and ref-to-ptr (&*T)
198
+ are valid constructs though. That means we can tell the debugger that ref-to-ref's are actually
199
+ ref-to-ptr's.
200
+
201
+ Additionally, to help debugger visualizers differentiate ref-to-ref's that *look like* ref-to-ptr
202
+ and *actual* ref-to-ptr, we can use the `rvalue_reference` tag. It's a C++ feature that doesn't
203
+ quite have an equivalent in Rust, but *is* represented as `&&` which is perfect! That means
204
+ ref-to-refs (&&T) will look like `T *&&` (i.e. an rvalue_reference to a pointer to T)
205
+ and on the debugger visualizer end, the scripts can "undo" that translation.
206
+
207
+ To handle immutable vs mutable (&/&mut) we use the `const` modifier. The modifier is applied
208
+ with proper C/C++ rules (i.e. pointer-to-constant vs constant pointer). This means that an
209
+ immutable reference applies the const modifier to the *pointee type*. When reversing the
210
+ debuginfo translation, the `const` modifier doesn't describe the value it's applied to, it describes
211
+ the pointer to the value. This is a **very** important distinction.
212
+
213
+ Here are some examples, the Rust representation is on the left and the debuginfo translation on
214
+ the right
215
+
216
+ Cosnt vs Mut:
217
+ *const T -> const T *
218
+ *mut T -> T *
219
+
220
+ *const *const T -> const T *const *
221
+ *mut *mut T -> T **
222
+
223
+ *mut *const T -> const T **
224
+ *const *mut T -> T *const *
225
+
226
+ Nested References:
227
+ &T -> const T &
228
+ &&T -> const T *const &&
229
+ &&&T -> const T &const *const &&
230
+ &&&&T -> const T *const &&const *const &&
231
+
232
+ &mut T -> T &
233
+ &mut &mut T -> T *&&
234
+ &mut &mut &mut T -> T &*&&
235
+ &mut &mut &mut &mut T -> T *&&*&&
236
+ */
237
237
let di_node = match ( ptr_type. kind ( ) , pointee_type. kind ( ) ) {
238
238
// if we have a ref-to-ref, convert the inner ref to a ptr and the outter ref to an rvalue ref
239
239
// and apply `const` to the inner ref's value and the inner ref itself as necessary
@@ -1009,8 +1009,8 @@ pub(crate) fn build_compile_unit_di_node<'ll, 'tcx>(
1009
1009
codegen_unit_name : & str ,
1010
1010
debug_context : & CodegenUnitDebugContext < ' ll , ' tcx > ,
1011
1011
) -> & ' ll DIDescriptor {
1012
- use rustc_session:: config:: RemapPathScopeComponents ;
1013
1012
use rustc_session:: RemapFileNameExt ;
1013
+ use rustc_session:: config:: RemapPathScopeComponents ;
1014
1014
let mut name_in_debuginfo = tcx
1015
1015
. sess
1016
1016
. local_crate_source_file ( )
0 commit comments