rustc_codegen_llvm: use safe references for Metadata and DI*.
This commit is contained in:
parent
6d0d82ce10
commit
eed48f560f
12 changed files with 410 additions and 376 deletions
|
@ -17,10 +17,9 @@ use rustc::hir::def_id::DefId;
|
|||
use rustc::ty::DefIdTree;
|
||||
|
||||
use llvm;
|
||||
use llvm::debuginfo::{DIScope, DIBuilder, DIDescriptor_opaque, DIArray};
|
||||
use llvm::debuginfo::{DIScope, DIBuilder, DIDescriptor, DIArray};
|
||||
use common::{CodegenCx};
|
||||
|
||||
use std::ptr::NonNull;
|
||||
use syntax_pos::{self, Span};
|
||||
|
||||
pub fn is_node_local_to_unit(cx: &CodegenCx, def_id: DefId) -> bool
|
||||
|
@ -37,7 +36,7 @@ pub fn is_node_local_to_unit(cx: &CodegenCx, def_id: DefId) -> bool
|
|||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn create_DIArray(builder: &DIBuilder, arr: &[Option<NonNull<DIDescriptor_opaque>>]) -> DIArray {
|
||||
pub fn create_DIArray(builder: &'ll DIBuilder, arr: &[Option<&'ll DIDescriptor>]) -> &'ll DIArray {
|
||||
return unsafe {
|
||||
llvm::LLVMRustDIBuilderGetOrCreateArray(builder, arr.as_ptr(), arr.len() as u32)
|
||||
};
|
||||
|
@ -49,7 +48,7 @@ pub fn span_start(cx: &CodegenCx, span: Span) -> syntax_pos::Loc {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn debug_context(cx: &'a CodegenCx<'ll, 'tcx>) -> &'a CrateDebugContext<'a, 'tcx> {
|
||||
pub fn debug_context(cx: &'a CodegenCx<'ll, 'tcx>) -> &'a CrateDebugContext<'ll, 'tcx> {
|
||||
cx.dbg_cx.as_ref().unwrap()
|
||||
}
|
||||
|
||||
|
@ -59,7 +58,7 @@ pub fn DIB(cx: &CodegenCx<'ll, '_>) -> &'ll DIBuilder {
|
|||
cx.dbg_cx.as_ref().unwrap().builder
|
||||
}
|
||||
|
||||
pub fn get_namespace_for_item(cx: &CodegenCx, def_id: DefId) -> DIScope {
|
||||
pub fn get_namespace_for_item(cx: &CodegenCx<'ll, '_>, def_id: DefId) -> &'ll DIScope {
|
||||
item_namespace(cx, cx.tcx.parent(def_id)
|
||||
.expect("get_namespace_for_item: missing parent?"))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue