From 249d5acaec0b10ee15b21b888977b5445baba42e Mon Sep 17 00:00:00 2001 From: Irina Popa Date: Wed, 27 Jun 2018 17:57:25 +0300 Subject: rustc_codegen_llvm: use safe references for Context and Module. --- src/librustc_codegen_llvm/debuginfo/metadata.rs | 2 +- src/librustc_codegen_llvm/debuginfo/mod.rs | 12 ++++++------ src/librustc_codegen_llvm/debuginfo/utils.rs | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/librustc_codegen_llvm/debuginfo') diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index 59c14a6910b..e7a6dc45222 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -862,7 +862,7 @@ pub fn compile_unit_metadata(tcx: TyCtxt, return unit_metadata; }; - fn path_to_mdstring(llcx: llvm::ContextRef, path: &Path) -> llvm::ValueRef { + fn path_to_mdstring(llcx: &llvm::Context, path: &Path) -> llvm::ValueRef { let path_str = path2cstr(path); unsafe { llvm::LLVMMDStringInContext(llcx, diff --git a/src/librustc_codegen_llvm/debuginfo/mod.rs b/src/librustc_codegen_llvm/debuginfo/mod.rs index fcabd273326..d4b51106033 100644 --- a/src/librustc_codegen_llvm/debuginfo/mod.rs +++ b/src/librustc_codegen_llvm/debuginfo/mod.rs @@ -21,7 +21,7 @@ use self::metadata::{type_metadata, file_metadata, TypeMap}; use self::source_loc::InternalDebugLocation::{self, UnknownLocation}; use llvm; -use llvm::{ModuleRef, ContextRef, ValueRef}; +use llvm::ValueRef; use llvm::debuginfo::{DIFile, DIType, DIScope, DIBuilderRef, DISubprogram, DIArray, DIFlags}; use rustc::hir::CodegenFnAttrFlags; use rustc::hir::def_id::{DefId, CrateNum}; @@ -67,9 +67,9 @@ const DW_TAG_auto_variable: c_uint = 0x100; const DW_TAG_arg_variable: c_uint = 0x101; /// A context object for maintaining all state needed by the debuginfo module. -pub struct CrateDebugContext<'tcx> { - llcontext: ContextRef, - llmod: ModuleRef, +pub struct CrateDebugContext<'a, 'tcx> { + llcontext: &'a llvm::Context, + llmod: &'a llvm::Module, builder: DIBuilderRef, created_files: RefCell>, created_enum_disr_types: RefCell>, @@ -82,8 +82,8 @@ pub struct CrateDebugContext<'tcx> { composite_types_completed: RefCell>, } -impl<'tcx> CrateDebugContext<'tcx> { - pub fn new(llmod: ModuleRef) -> CrateDebugContext<'tcx> { +impl<'a, 'tcx> CrateDebugContext<'a, 'tcx> { + pub fn new(llmod: &'a llvm::Module) -> Self { debug!("CrateDebugContext::new"); let builder = unsafe { llvm::LLVMRustDIBuilderCreate(llmod) }; // DIBuilder inherits context from the module, so we'd better use the same one diff --git a/src/librustc_codegen_llvm/debuginfo/utils.rs b/src/librustc_codegen_llvm/debuginfo/utils.rs index 87da3316628..85cddb0a580 100644 --- a/src/librustc_codegen_llvm/debuginfo/utils.rs +++ b/src/librustc_codegen_llvm/debuginfo/utils.rs @@ -50,7 +50,7 @@ pub fn span_start(cx: &CodegenCx, span: Span) -> syntax_pos::Loc { #[inline] pub fn debug_context<'a, 'tcx>(cx: &'a CodegenCx<'a, 'tcx>) - -> &'a CrateDebugContext<'tcx> { + -> &'a CrateDebugContext<'a, 'tcx> { cx.dbg_cx.as_ref().unwrap() } -- cgit 1.4.1-3-g733a5