diff options
| author | Denis Merigoux <denis.merigoux@gmail.com> | 2018-09-13 14:58:19 +0200 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2018-11-16 14:15:13 +0200 |
| commit | 034f69753b3e934789377cd6fa2b8c3f46364da0 (patch) | |
| tree | b5746f1c4883211b58111deec7c8b2b870c4d462 /src/librustc_codegen_llvm/debuginfo | |
| parent | 484e07c231e29febc68f2f21e970f8eb19818ad6 (diff) | |
| download | rust-034f69753b3e934789377cd6fa2b8c3f46364da0.tar.gz rust-034f69753b3e934789377cd6fa2b8c3f46364da0.zip | |
Generalized base::unsized_info
Diffstat (limited to 'src/librustc_codegen_llvm/debuginfo')
| -rw-r--r-- | src/librustc_codegen_llvm/debuginfo/metadata.rs | 105 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/debuginfo/mod.rs | 1 |
2 files changed, 54 insertions, 52 deletions
diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index 5581b926ccd..923b04c0ecc 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -17,6 +17,7 @@ use super::utils::{debug_context, DIB, span_start, use super::namespace::mangled_name_of_instance; use super::type_names::compute_debuginfo_type_name; use super::{CrateDebugContext}; +use interfaces::*; use abi; use interfaces::ConstMethods; use value::Value; @@ -1983,58 +1984,60 @@ pub fn extend_scope_to_file( } } -/// Creates debug information for the given vtable, which is for the -/// given type. -/// -/// Adds the created metadata nodes directly to the crate's IR. -pub fn create_vtable_metadata( - cx: &CodegenCx<'ll, 'tcx>, - ty: ty::Ty<'tcx>, - vtable: &'ll Value, -) { - if cx.dbg_cx.is_none() { - return; - } - - let type_metadata = type_metadata(cx, ty, syntax_pos::DUMMY_SP); - - unsafe { - // LLVMRustDIBuilderCreateStructType() wants an empty array. A null - // pointer will lead to hard to trace and debug LLVM assertions - // later on in llvm/lib/IR/Value.cpp. - let empty_array = create_DIArray(DIB(cx), &[]); - - let name = const_cstr!("vtable"); +impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { + /// Creates debug information for the given vtable, which is for the + /// given type. + /// + /// Adds the created metadata nodes directly to the crate's IR. + fn create_vtable_metadata( + &self, + ty: ty::Ty<'tcx>, + vtable: &'ll Value, + ) { + if self.dbg_cx.is_none() { + return; + } - // Create a new one each time. We don't want metadata caching - // here, because each vtable will refer to a unique containing - // type. - let vtable_type = llvm::LLVMRustDIBuilderCreateStructType( - DIB(cx), - NO_SCOPE_METADATA, - name.as_ptr(), - unknown_file_metadata(cx), - UNKNOWN_LINE_NUMBER, - Size::ZERO.bits(), - cx.tcx.data_layout.pointer_align.abi_bits() as u32, - DIFlags::FlagArtificial, - None, - empty_array, - 0, - Some(type_metadata), - name.as_ptr() - ); + let type_metadata = type_metadata(&self, ty, syntax_pos::DUMMY_SP); - llvm::LLVMRustDIBuilderCreateStaticVariable(DIB(cx), - NO_SCOPE_METADATA, - name.as_ptr(), - ptr::null(), - unknown_file_metadata(cx), - UNKNOWN_LINE_NUMBER, - vtable_type, - true, - vtable, - None, - 0); + unsafe { + // LLVMRustDIBuilderCreateStructType() wants an empty array. A null + // pointer will lead to hard to trace and debug LLVM assertions + // later on in llvm/lib/IR/Value.cpp. + let empty_array = create_DIArray(DIB(&self), &[]); + + let name = const_cstr!("vtable"); + + // Create a new one each time. We don't want metadata caching + // here, because each vtable will refer to a unique containing + // type. + let vtable_type = llvm::LLVMRustDIBuilderCreateStructType( + DIB(&self), + NO_SCOPE_METADATA, + name.as_ptr(), + unknown_file_metadata(&self), + UNKNOWN_LINE_NUMBER, + Size::ZERO.bits(), + self.tcx.data_layout.pointer_align.abi_bits() as u32, + DIFlags::FlagArtificial, + None, + empty_array, + 0, + Some(type_metadata), + name.as_ptr() + ); + + llvm::LLVMRustDIBuilderCreateStaticVariable(DIB(&self), + NO_SCOPE_METADATA, + name.as_ptr(), + ptr::null(), + unknown_file_metadata(&self), + UNKNOWN_LINE_NUMBER, + vtable_type, + true, + vtable, + None, + 0); + } } } diff --git a/src/librustc_codegen_llvm/debuginfo/mod.rs b/src/librustc_codegen_llvm/debuginfo/mod.rs index 0ee51f1956b..9fcd57a1ec5 100644 --- a/src/librustc_codegen_llvm/debuginfo/mod.rs +++ b/src/librustc_codegen_llvm/debuginfo/mod.rs @@ -58,7 +58,6 @@ mod source_loc; pub use self::create_scope_map::{create_mir_scopes, MirDebugScope}; pub use self::source_loc::start_emitting_source_locations; pub use self::metadata::create_global_var_metadata; -pub use self::metadata::create_vtable_metadata; pub use self::metadata::extend_scope_to_file; pub use self::source_loc::set_source_location; |
