@@ -74,6 +74,11 @@ 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_reference_type : c_uint = 0x10 ;
79
+ #[ allow( non_upper_case_globals) ]
80
+ const DW_TAG_const_type : c_uint = 0x26 ;
81
+
77
82
pub ( super ) const UNKNOWN_LINE_NUMBER : c_uint = 0 ;
78
83
pub ( super ) const UNKNOWN_COLUMN_NUMBER : c_uint = 0 ;
79
84
@@ -181,16 +186,61 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
181
186
"ptr_type={ptr_type}, pointee_type={pointee_type}" ,
182
187
) ;
183
188
184
- let di_node = unsafe {
185
- llvm:: LLVMRustDIBuilderCreatePointerType (
186
- DIB ( cx) ,
187
- pointee_type_di_node,
188
- data_layout. pointer_size . bits ( ) ,
189
- data_layout. pointer_align . abi . bits ( ) as u32 ,
190
- 0 , // Ignore DWARF address space.
191
- ptr_type_debuginfo_name. as_c_char_ptr ( ) ,
192
- ptr_type_debuginfo_name. len ( ) ,
193
- )
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 ( ) {
197
+ llvm:: LLVMRustDIBuilderCreateQualifiedType (
198
+ DIB ( cx) ,
199
+ DW_TAG_const_type ,
200
+ pointee_type_di_node,
201
+ )
202
+ } else {
203
+ pointee_type_di_node
204
+ } ;
205
+
206
+ llvm:: LLVMRustDIBuilderCreateReferenceType (
207
+ DIB ( cx) ,
208
+ DW_TAG_reference_type ,
209
+ pointee_type_di_node,
210
+ )
211
+ } ,
212
+ ty:: RawPtr ( _, mutability) => unsafe {
213
+ let pointee_type_di_node = if mutability. is_not ( ) {
214
+ llvm:: LLVMRustDIBuilderCreateQualifiedType (
215
+ DIB ( cx) ,
216
+ DW_TAG_const_type ,
217
+ pointee_type_di_node,
218
+ )
219
+ } else {
220
+ pointee_type_di_node
221
+ } ;
222
+ llvm:: LLVMRustDIBuilderCreatePointerType (
223
+ DIB ( cx) ,
224
+ pointee_type_di_node,
225
+ data_layout. pointer_size . bits ( ) ,
226
+ data_layout. pointer_align . abi . bits ( ) as u32 ,
227
+ 0 , // Ignore DWARF address space.
228
+ ptr_type_debuginfo_name. as_c_char_ptr ( ) ,
229
+ ptr_type_debuginfo_name. len ( ) ,
230
+ )
231
+ } ,
232
+ ty:: Adt ( _, _) => unsafe {
233
+ llvm:: LLVMRustDIBuilderCreatePointerType (
234
+ DIB ( cx) ,
235
+ pointee_type_di_node,
236
+ data_layout. pointer_size . bits ( ) ,
237
+ data_layout. pointer_align . abi . bits ( ) as u32 ,
238
+ 0 , // Ignore DWARF address space.
239
+ ptr_type_debuginfo_name. as_c_char_ptr ( ) ,
240
+ ptr_type_debuginfo_name. len ( ) ,
241
+ )
242
+ } ,
243
+ _ => unreachable ! ( "Thin pointer not of type ty::RawPtr, ty::Ref, or ty::Adt" ) ,
194
244
} ;
195
245
196
246
DINodeCreationResult { di_node, already_stored_in_typemap : false }
0 commit comments