rustc_codegen_llvm: fix ownership of DIBuilder.
This commit is contained in:
parent
54c98ab0dd
commit
69ed6b928c
3 changed files with 45 additions and 34 deletions
|
@ -69,7 +69,7 @@ const DW_TAG_arg_variable: c_uint = 0x101;
|
|||
pub struct CrateDebugContext<'a, 'tcx> {
|
||||
llcontext: &'a llvm::Context,
|
||||
llmod: &'a llvm::Module,
|
||||
builder: &'a DIBuilder,
|
||||
builder: &'a mut DIBuilder<'a>,
|
||||
created_files: RefCell<FxHashMap<(Symbol, Symbol), &'a DIFile>>,
|
||||
created_enum_disr_types: RefCell<FxHashMap<(DefId, layout::Primitive), &'a DIType>>,
|
||||
|
||||
|
@ -81,6 +81,14 @@ pub struct CrateDebugContext<'a, 'tcx> {
|
|||
composite_types_completed: RefCell<FxHashSet<&'a DIType>>,
|
||||
}
|
||||
|
||||
impl Drop for CrateDebugContext<'a, 'tcx> {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
llvm::LLVMRustDIBuilderDispose(&mut *(self.builder as *mut _));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> CrateDebugContext<'a, 'tcx> {
|
||||
pub fn new(llmod: &'a llvm::Module) -> Self {
|
||||
debug!("CrateDebugContext::new");
|
||||
|
@ -166,7 +174,6 @@ pub fn finalize(cx: &CodegenCx) {
|
|||
|
||||
unsafe {
|
||||
llvm::LLVMRustDIBuilderFinalize(DIB(cx));
|
||||
llvm::LLVMRustDIBuilderDispose(DIB(cx));
|
||||
// Debuginfo generation in LLVM by default uses a higher
|
||||
// version of dwarf than macOS currently understands. We can
|
||||
// instruct LLVM to emit an older version of dwarf, however,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue