Create a safe wrapper around LLVMRustDIBuilderCreateSubroutineType
This commit is contained in:
parent
6adc2c1fd6
commit
e19e4e3a4b
2 changed files with 13 additions and 12 deletions
|
@ -38,8 +38,8 @@ use crate::debuginfo::metadata::type_map::build_type_with_children;
|
|||
use crate::debuginfo::utils::{WidePtrKind, wide_pointer_kind};
|
||||
use crate::llvm;
|
||||
use crate::llvm::debuginfo::{
|
||||
DIDescriptor, DIFile, DIFlags, DILexicalBlock, DIScope, DIType, DebugEmissionKind,
|
||||
DebugNameTableKind,
|
||||
DICompositeType, DIDescriptor, DIFile, DIFlags, DILexicalBlock, DIScope, DIType,
|
||||
DebugEmissionKind, DebugNameTableKind,
|
||||
};
|
||||
use crate::value::Value;
|
||||
|
||||
|
@ -312,12 +312,7 @@ fn build_subroutine_type_di_node<'ll, 'tcx>(
|
|||
|
||||
debug_context(cx).type_map.unique_id_to_di_node.borrow_mut().remove(&unique_type_id);
|
||||
|
||||
let fn_di_node = unsafe {
|
||||
llvm::LLVMRustDIBuilderCreateSubroutineType(
|
||||
DIB(cx),
|
||||
create_DIArray(DIB(cx), &signature_di_nodes[..]),
|
||||
)
|
||||
};
|
||||
let fn_di_node = create_subroutine_type(cx, create_DIArray(DIB(cx), &signature_di_nodes[..]));
|
||||
|
||||
// This is actually a function pointer, so wrap it in pointer DI.
|
||||
let name = compute_debuginfo_type_name(cx.tcx, fn_ty, false);
|
||||
|
@ -341,6 +336,13 @@ fn build_subroutine_type_di_node<'ll, 'tcx>(
|
|||
DINodeCreationResult::new(di_node, false)
|
||||
}
|
||||
|
||||
pub(super) fn create_subroutine_type<'ll>(
|
||||
cx: &CodegenCx<'ll, '_>,
|
||||
signature: &'ll DICompositeType,
|
||||
) -> &'ll DICompositeType {
|
||||
unsafe { llvm::LLVMRustDIBuilderCreateSubroutineType(DIB(cx), signature) }
|
||||
}
|
||||
|
||||
/// Create debuginfo for `dyn SomeTrait` types. Currently these are empty structs
|
||||
/// we with the correct type name (e.g. "dyn SomeTrait<Foo, Item=u32> + Sync").
|
||||
fn build_dyn_type_di_node<'ll, 'tcx>(
|
||||
|
|
|
@ -6,6 +6,7 @@ use std::ptr;
|
|||
use std::sync::Arc;
|
||||
|
||||
use libc::c_uint;
|
||||
use metadata::create_subroutine_type;
|
||||
use rustc_abi::Size;
|
||||
use rustc_codegen_ssa::debuginfo::type_names;
|
||||
use rustc_codegen_ssa::mir::debuginfo::VariableKind::*;
|
||||
|
@ -341,10 +342,8 @@ impl<'ll, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||
let loc = self.lookup_debug_loc(span.lo());
|
||||
let file_metadata = file_metadata(self, &loc.file);
|
||||
|
||||
let function_type_metadata = unsafe {
|
||||
let fn_signature = get_function_signature(self, fn_abi);
|
||||
llvm::LLVMRustDIBuilderCreateSubroutineType(DIB(self), fn_signature)
|
||||
};
|
||||
let function_type_metadata =
|
||||
create_subroutine_type(self, get_function_signature(self, fn_abi));
|
||||
|
||||
let mut name = String::with_capacity(64);
|
||||
type_names::push_item_name(tcx, def_id, false, &mut name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue