@@ -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:: { VTableNameKind , cpp_like_debuginfo } ;
9
+ use rustc_codegen_ssa:: debuginfo:: type_names:: { cpp_like_debuginfo , VTableNameKind } ;
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:: { DUMMY_SP , FileName , FileNameDisplayPreference , SourceFile , hygiene } ;
20
+ use rustc_span:: { hygiene , FileName , FileNameDisplayPreference , SourceFile , DUMMY_SP } ;
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 ;
28
27
use super :: namespace:: mangled_name_of_instance;
29
28
use super :: type_names:: { compute_debuginfo_type_name, compute_debuginfo_vtable_name} ;
30
29
use super :: utils:: {
31
- DIB , create_DIArray, debug_context, get_namespace_for_item, is_node_local_to_unit,
30
+ create_DIArray, debug_context, get_namespace_for_item, is_node_local_to_unit, DIB ,
32
31
} ;
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:: { WidePtrKind , wide_pointer_kind } ;
35
+ use crate :: debuginfo:: utils:: { wide_pointer_kind , WidePtrKind } ;
36
36
use crate :: llvm:: debuginfo:: {
37
37
DIDescriptor , DIFile , DIFlags , DILexicalBlock , DIScope , DIType , DebugEmissionKind ,
38
38
DebugNameTableKind ,
@@ -74,10 +74,14 @@ const DW_ATE_unsigned: c_uint = 0x07;
74
74
#[ allow( non_upper_case_globals) ]
75
75
const DW_ATE_UTF : c_uint = 0x10 ;
76
76
77
+ #[ allow( non_upper_case_globals) ]
78
+ const DW_TAG_pointer_type : c_uint = 0xf ;
77
79
#[ allow( non_upper_case_globals) ]
78
80
const DW_TAG_reference_type : c_uint = 0x10 ;
79
81
#[ allow( non_upper_case_globals) ]
80
82
const DW_TAG_const_type : c_uint = 0x26 ;
83
+ #[ allow( non_upper_case_globals) ]
84
+ const DW_TAG_rvalue_reference_type : c_uint = 0x42 ;
81
85
82
86
pub ( super ) const UNKNOWN_LINE_NUMBER : c_uint = 0 ;
83
87
pub ( super ) const UNKNOWN_COLUMN_NUMBER : c_uint = 0 ;
@@ -186,14 +190,43 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
186
190
"ptr_type={ptr_type}, pointee_type={pointee_type}" ,
187
191
) ;
188
192
189
- // Immutable pointers/references will mark the data as `const`. For example:
190
- // unsigned char & => &mut u8
191
- // const unsigned char & => &u8
192
- // unsigned char * => *mut u8
193
- // const unsigned char * => *const u8
194
- let di_node = match ptr_type. kind ( ) {
195
- ty:: Ref ( _, _, mutability) => unsafe {
196
- let pointee_type_di_node = if mutability. is_not ( ) {
193
+ let di_node = match ( ptr_type. kind ( ) , pointee_type. kind ( ) ) {
194
+ ( ty:: Ref ( _, _, ptr_mut) , ty:: Ref ( _, inner_type, ptee_mut) ) => unsafe {
195
+ let inner_type_di_node = type_di_node ( cx, * inner_type) ;
196
+ let inner_type_di_node = if ptee_mut. is_not ( ) {
197
+ llvm:: LLVMRustDIBuilderCreateQualifiedType (
198
+ DIB ( cx) ,
199
+ DW_TAG_const_type ,
200
+ inner_type_di_node,
201
+ )
202
+ } else {
203
+ inner_type_di_node
204
+ } ;
205
+
206
+ let ptr_wrapper = llvm:: LLVMRustDIBuilderCreateReferenceType (
207
+ DIB ( cx) ,
208
+ DW_TAG_pointer_type ,
209
+ inner_type_di_node,
210
+ ) ;
211
+
212
+ let ptr_wrapper = if ptr_mut. is_not ( ) {
213
+ llvm:: LLVMRustDIBuilderCreateQualifiedType (
214
+ DIB ( cx) ,
215
+ DW_TAG_const_type ,
216
+ ptr_wrapper,
217
+ )
218
+ } else {
219
+ ptr_wrapper
220
+ } ;
221
+
222
+ llvm:: LLVMRustDIBuilderCreateReferenceType (
223
+ DIB ( cx) ,
224
+ DW_TAG_rvalue_reference_type ,
225
+ ptr_wrapper,
226
+ )
227
+ } ,
228
+ ( ty:: Ref ( _, _, ptr_mut) , _) => unsafe {
229
+ let pointee_type_di_node = if ptr_mut. is_not ( ) {
197
230
llvm:: LLVMRustDIBuilderCreateQualifiedType (
198
231
DIB ( cx) ,
199
232
DW_TAG_const_type ,
@@ -209,8 +242,8 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
209
242
pointee_type_di_node,
210
243
)
211
244
} ,
212
- ty:: RawPtr ( _, mutability ) => unsafe {
213
- let pointee_type_di_node = if mutability . is_not ( ) {
245
+ ( ty:: RawPtr ( _, ptr_mut ) , _ ) => unsafe {
246
+ let pointee_type_di_node = if ptr_mut . is_not ( ) {
214
247
llvm:: LLVMRustDIBuilderCreateQualifiedType (
215
248
DIB ( cx) ,
216
249
DW_TAG_const_type ,
@@ -219,6 +252,7 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
219
252
} else {
220
253
pointee_type_di_node
221
254
} ;
255
+
222
256
llvm:: LLVMRustDIBuilderCreatePointerType (
223
257
DIB ( cx) ,
224
258
pointee_type_di_node,
@@ -229,7 +263,7 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
229
263
ptr_type_debuginfo_name. len ( ) ,
230
264
)
231
265
} ,
232
- ty:: Adt ( _, _) => unsafe {
266
+ ( ty:: Adt ( _, _ ) , _) => unsafe {
233
267
llvm:: LLVMRustDIBuilderCreatePointerType (
234
268
DIB ( cx) ,
235
269
pointee_type_di_node,
@@ -240,9 +274,91 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
240
274
ptr_type_debuginfo_name. len ( ) ,
241
275
)
242
276
} ,
243
- _ => unreachable ! ( "Thin pointer not of type ty::RawPtr, ty::Ref, or ty::Adt" ) ,
277
+ _ => todo ! ( ) ,
244
278
} ;
245
279
280
+ // Immutable pointers/references will mark the data as `const`. For example:
281
+ // unsigned char & => &mut u8
282
+ // const unsigned char & => &u8
283
+ // unsigned char * => *mut u8
284
+ // const unsigned char * => *const u8
285
+ // let di_node = match ptr_type.kind() {
286
+ // ty::Ref(_, _, mutability) => unsafe {
287
+ // let pointee_type_di_node = if mutability.is_not() {
288
+ // llvm::LLVMRustDIBuilderCreateQualifiedType(
289
+ // DIB(cx),
290
+ // DW_TAG_const_type,
291
+ // pointee_type_di_node,
292
+ // )
293
+ // } else {
294
+ // pointee_type_di_node
295
+ // };
296
+
297
+ // if let ty::Ref(_, pt_e, _) = pointee_type.kind() {
298
+ // let pointee_type_di_node = type_di_node(cx, *pt_e);
299
+ // let temp = llvm::LLVMRustDIBuilderCreateReferenceType(
300
+ // DIB(cx),
301
+ // 0xf,
302
+ // pointee_type_di_node,
303
+ // );
304
+
305
+ // let temp = if mutability.is_not() {
306
+ // llvm::LLVMRustDIBuilderCreateQualifiedType(
307
+ // DIB(cx),
308
+ // DW_TAG_const_type,
309
+ // temp,
310
+ // )
311
+ // } else {
312
+ // temp
313
+ // };
314
+
315
+ // llvm::LLVMRustDIBuilderCreateReferenceType(
316
+ // DIB(cx),
317
+ // DW_TAG_rvalue_reference_type,
318
+ // temp,
319
+ // )
320
+ // } else {
321
+ // llvm::LLVMRustDIBuilderCreateReferenceType(
322
+ // DIB(cx),
323
+ // DW_TAG_reference_type,
324
+ // pointee_type_di_node,
325
+ // )
326
+ // }
327
+ // },
328
+ // ty::RawPtr(_, mutability) => unsafe {
329
+ // let pointee_type_di_node = if mutability.is_not() {
330
+ // llvm::LLVMRustDIBuilderCreateQualifiedType(
331
+ // DIB(cx),
332
+ // DW_TAG_const_type,
333
+ // pointee_type_di_node,
334
+ // )
335
+ // } else {
336
+ // pointee_type_di_node
337
+ // };
338
+ // llvm::LLVMRustDIBuilderCreatePointerType(
339
+ // DIB(cx),
340
+ // pointee_type_di_node,
341
+ // data_layout.pointer_size.bits(),
342
+ // data_layout.pointer_align.abi.bits() as u32,
343
+ // 0, // Ignore DWARF address space.
344
+ // ptr_type_debuginfo_name.as_c_char_ptr(),
345
+ // ptr_type_debuginfo_name.len(),
346
+ // )
347
+ // },
348
+ // ty::Adt(_, _) => unsafe {
349
+ // llvm::LLVMRustDIBuilderCreatePointerType(
350
+ // DIB(cx),
351
+ // pointee_type_di_node,
352
+ // data_layout.pointer_size.bits(),
353
+ // data_layout.pointer_align.abi.bits() as u32,
354
+ // 0, // Ignore DWARF address space.
355
+ // ptr_type_debuginfo_name.as_c_char_ptr(),
356
+ // ptr_type_debuginfo_name.len(),
357
+ // )
358
+ // },
359
+ // _ => unreachable!("Thin pointer not of type ty::RawPtr, ty::Ref, or ty::Adt"),
360
+ // };
361
+
246
362
DINodeCreationResult { di_node, already_stored_in_typemap : false }
247
363
}
248
364
Some ( wide_pointer_kind) => {
@@ -923,8 +1039,8 @@ pub(crate) fn build_compile_unit_di_node<'ll, 'tcx>(
923
1039
codegen_unit_name : & str ,
924
1040
debug_context : & CodegenUnitDebugContext < ' ll , ' tcx > ,
925
1041
) -> & ' ll DIDescriptor {
926
- use rustc_session:: RemapFileNameExt ;
927
1042
use rustc_session:: config:: RemapPathScopeComponents ;
1043
+ use rustc_session:: RemapFileNameExt ;
928
1044
let mut name_in_debuginfo = tcx
929
1045
. sess
930
1046
. local_crate_source_file ( )
0 commit comments