diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-12-22 17:42:04 -0500 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-12-22 17:42:47 -0500 |
| commit | a06baa56b95674fc626b3c3fd680d6a65357fe60 (patch) | |
| tree | cd9d867c2ca3cff5c1d6b3bd73377c44649fb075 /src/librustc_codegen_llvm/debuginfo | |
| parent | 8eb7c58dbb7b32701af113bc58722d0d1fefb1eb (diff) | |
| download | rust-a06baa56b95674fc626b3c3fd680d6a65357fe60.tar.gz rust-a06baa56b95674fc626b3c3fd680d6a65357fe60.zip | |
Format the world
Diffstat (limited to 'src/librustc_codegen_llvm/debuginfo')
| -rw-r--r-- | src/librustc_codegen_llvm/debuginfo/create_scope_map.rs | 27 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/debuginfo/gdb.rs | 32 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/debuginfo/mod.rs | 200 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/debuginfo/namespace.rs | 22 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/debuginfo/source_loc.rs | 27 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/debuginfo/utils.rs | 17 |
6 files changed, 152 insertions, 173 deletions
diff --git a/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs b/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs index 91d5a22b022..206884d63c7 100644 --- a/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs +++ b/src/librustc_codegen_llvm/debuginfo/create_scope_map.rs @@ -1,10 +1,10 @@ -use rustc_codegen_ssa::mir::debuginfo::{FunctionDebugContext, DebugScope}; use super::metadata::file_metadata; -use super::utils::{DIB, span_start}; +use super::utils::{span_start, DIB}; +use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext}; +use crate::common::CodegenCx; use crate::llvm; use crate::llvm::debuginfo::{DIScope, DISubprogram}; -use crate::common::CodegenCx; use rustc::mir::{Body, SourceScope}; use libc::c_uint; @@ -36,12 +36,14 @@ pub fn compute_mir_scopes( } } -fn make_mir_scope(cx: &CodegenCx<'ll, '_>, - mir: &Body<'_>, - fn_metadata: &'ll DISubprogram, - has_variables: &BitSet<SourceScope>, - debug_context: &mut FunctionDebugContext<&'ll DISubprogram>, - scope: SourceScope) { +fn make_mir_scope( + cx: &CodegenCx<'ll, '_>, + mir: &Body<'_>, + fn_metadata: &'ll DISubprogram, + has_variables: &BitSet<SourceScope>, + debug_context: &mut FunctionDebugContext<&'ll DISubprogram>, + scope: SourceScope, +) { if debug_context.scopes[scope].is_valid() { return; } @@ -75,9 +77,7 @@ fn make_mir_scope(cx: &CodegenCx<'ll, '_>, } let loc = span_start(cx, scope_data.span); - let file_metadata = file_metadata(cx, - &loc.file.name, - debug_context.defining_crate); + let file_metadata = file_metadata(cx, &loc.file.name, debug_context.defining_crate); let scope_metadata = unsafe { Some(llvm::LLVMRustDIBuilderCreateLexicalBlock( @@ -85,7 +85,8 @@ fn make_mir_scope(cx: &CodegenCx<'ll, '_>, parent_scope.scope_metadata.unwrap(), file_metadata, loc.line as c_uint, - loc.col.to_usize() as c_uint)) + loc.col.to_usize() as c_uint, + )) }; debug_context.scopes[scope] = DebugScope { scope_metadata, diff --git a/src/librustc_codegen_llvm/debuginfo/gdb.rs b/src/librustc_codegen_llvm/debuginfo/gdb.rs index 739437ac27b..f68b7b2cfb9 100644 --- a/src/librustc_codegen_llvm/debuginfo/gdb.rs +++ b/src/librustc_codegen_llvm/debuginfo/gdb.rs @@ -2,17 +2,16 @@ use crate::llvm; -use crate::common::CodegenCx; use crate::builder::Builder; +use crate::common::CodegenCx; use crate::value::Value; +use rustc::bug; use rustc::session::config::DebugInfo; use rustc_codegen_ssa::traits::*; -use rustc::bug; use syntax::attr; use syntax::symbol::sym; - /// Inserts a side-effect free instruction sequence that makes sure that the /// .debug_gdb_scripts global is referenced, so it isn't removed by the linker. pub fn insert_reference_to_gdb_debug_scripts_section_global(bx: &mut Builder<'_, '_, '_>) { @@ -31,28 +30,23 @@ pub fn insert_reference_to_gdb_debug_scripts_section_global(bx: &mut Builder<'_, /// Allocates the global variable responsible for the .debug_gdb_scripts binary /// section. -pub fn get_or_insert_gdb_debug_scripts_section_global(cx: &CodegenCx<'ll, '_>) - -> &'ll Value { +pub fn get_or_insert_gdb_debug_scripts_section_global(cx: &CodegenCx<'ll, '_>) -> &'ll Value { let c_section_var_name = "__rustc_debug_gdb_scripts_section__\0"; - let section_var_name = &c_section_var_name[..c_section_var_name.len()-1]; + let section_var_name = &c_section_var_name[..c_section_var_name.len() - 1]; - let section_var = unsafe { - llvm::LLVMGetNamedGlobal(cx.llmod, - c_section_var_name.as_ptr().cast()) - }; + let section_var = + unsafe { llvm::LLVMGetNamedGlobal(cx.llmod, c_section_var_name.as_ptr().cast()) }; section_var.unwrap_or_else(|| { let section_name = b".debug_gdb_scripts\0"; let section_contents = b"\x01gdb_load_rust_pretty_printers.py\0"; unsafe { - let llvm_type = cx.type_array(cx.type_i8(), - section_contents.len() as u64); + let llvm_type = cx.type_array(cx.type_i8(), section_contents.len() as u64); - let section_var = cx.define_global(section_var_name, - llvm_type).unwrap_or_else(||{ - bug!("symbol `{}` is already defined", section_var_name) - }); + let section_var = cx + .define_global(section_var_name, llvm_type) + .unwrap_or_else(|| bug!("symbol `{}` is already defined", section_var_name)); llvm::LLVMSetSection(section_var, section_name.as_ptr().cast()); llvm::LLVMSetInitializer(section_var, cx.const_bytes(section_contents)); llvm::LLVMSetGlobalConstant(section_var, llvm::True); @@ -70,7 +64,7 @@ pub fn needs_gdb_debug_scripts_section(cx: &CodegenCx<'_, '_>) -> bool { let omit_gdb_pretty_printer_section = attr::contains_name(&cx.tcx.hir().krate_attrs(), sym::omit_gdb_pretty_printer_section); - !omit_gdb_pretty_printer_section && - cx.sess().opts.debuginfo != DebugInfo::None && - cx.sess().target.target.options.emit_debug_gdb_scripts + !omit_gdb_pretty_printer_section + && cx.sess().opts.debuginfo != DebugInfo::None + && cx.sess().target.target.options.emit_debug_gdb_scripts } diff --git a/src/librustc_codegen_llvm/debuginfo/mod.rs b/src/librustc_codegen_llvm/debuginfo/mod.rs index 1de298de75f..8c6d1ce695b 100644 --- a/src/librustc_codegen_llvm/debuginfo/mod.rs +++ b/src/librustc_codegen_llvm/debuginfo/mod.rs @@ -3,51 +3,51 @@ mod doc; use rustc_codegen_ssa::mir::debuginfo::VariableKind::*; -use self::utils::{DIB, span_start, create_DIArray, is_node_local_to_unit}; +use self::metadata::{file_metadata, type_metadata, TypeMap}; use self::namespace::mangled_name_of_instance; -use self::type_names::compute_debuginfo_type_name; -use self::metadata::{type_metadata, file_metadata, TypeMap}; use self::source_loc::InternalDebugLocation::{self, UnknownLocation}; +use self::type_names::compute_debuginfo_type_name; +use self::utils::{create_DIArray, is_node_local_to_unit, span_start, DIB}; use crate::llvm; -use crate::llvm::debuginfo::{DIFile, DIType, DIScope, DIBuilder, DIArray, DIFlags, - DISPFlags, DILexicalBlock}; +use crate::llvm::debuginfo::{ + DIArray, DIBuilder, DIFile, DIFlags, DILexicalBlock, DISPFlags, DIScope, DIType, +}; +use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; use rustc::hir::CodegenFnAttrFlags; -use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE}; -use rustc::ty::subst::{SubstsRef, GenericArgKind}; +use rustc::ty::subst::{GenericArgKind, SubstsRef}; use crate::abi::FnAbi; -use crate::common::CodegenCx; use crate::builder::Builder; +use crate::common::CodegenCx; use crate::value::Value; -use rustc::ty::{self, ParamEnv, Ty, InstanceDef, Instance}; use rustc::mir; use rustc::session::config::{self, DebugInfo}; +use rustc::ty::{self, Instance, InstanceDef, ParamEnv, Ty}; use rustc::util::nodemap::{DefIdMap, FxHashMap, FxHashSet}; +use rustc_codegen_ssa::debuginfo::type_names; +use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext, VariableKind}; use rustc_data_structures::small_c_str::SmallCStr; use rustc_index::vec::IndexVec; -use rustc_codegen_ssa::debuginfo::type_names; -use rustc_codegen_ssa::mir::debuginfo::{FunctionDebugContext, DebugScope, - VariableKind}; use libc::c_uint; +use log::debug; use std::cell::RefCell; use std::ffi::CString; -use log::debug; +use rustc::ty::layout::{self, HasTyCtxt, LayoutOf, Size}; +use rustc_codegen_ssa::traits::*; use smallvec::SmallVec; -use syntax_pos::{self, BytePos, Span, Pos}; use syntax::ast; use syntax::symbol::Symbol; -use rustc::ty::layout::{self, LayoutOf, HasTyCtxt, Size}; -use rustc_codegen_ssa::traits::*; +use syntax_pos::{self, BytePos, Pos, Span}; +mod create_scope_map; pub mod gdb; -mod utils; -mod namespace; pub mod metadata; -mod create_scope_map; +mod namespace; mod source_loc; +mod utils; pub use self::create_scope_map::compute_mir_scopes; pub use self::metadata::create_global_var_metadata; @@ -126,24 +126,20 @@ pub fn finalize(cx: &CodegenCx<'_, '_>) { // for macOS to understand. For more info see #11352 // This can be overridden using --llvm-opts -dwarf-version,N. // Android has the same issue (#22398) - if cx.sess().target.target.options.is_like_osx || - cx.sess().target.target.options.is_like_android { - llvm::LLVMRustAddModuleFlag(cx.llmod, - "Dwarf Version\0".as_ptr().cast(), - 2) + if cx.sess().target.target.options.is_like_osx + || cx.sess().target.target.options.is_like_android + { + llvm::LLVMRustAddModuleFlag(cx.llmod, "Dwarf Version\0".as_ptr().cast(), 2) } // Indicate that we want CodeView debug information on MSVC if cx.sess().target.target.options.is_like_msvc { - llvm::LLVMRustAddModuleFlag(cx.llmod, - "CodeView\0".as_ptr().cast(), - 1) + llvm::LLVMRustAddModuleFlag(cx.llmod, "CodeView\0".as_ptr().cast(), 1) } // Prevent bitcode readers from deleting the debug info. let ptr = "Debug Info Version\0".as_ptr(); - llvm::LLVMRustAddModuleFlag(cx.llmod, ptr.cast(), - llvm::LLVMRustDebugMetadataVersion()); + llvm::LLVMRustAddModuleFlag(cx.llmod, ptr.cast(), llvm::LLVMRustDebugMetadataVersion()); }; } @@ -164,16 +160,14 @@ impl DebugInfoBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> { let cx = self.cx(); let file = span_start(cx, span).file; - let file_metadata = file_metadata(cx, - &file.name, - dbg_context.defining_crate); + let file_metadata = file_metadata(cx, &file.name, dbg_context.defining_crate); let loc = span_start(cx, span); let type_metadata = type_metadata(cx, variable_type, span); let (argument_index, dwarf_tag) = match variable_kind { ArgumentVariable(index) => (index as c_uint, DW_TAG_arg_variable), - LocalVariable => (0, DW_TAG_auto_variable) + LocalVariable => (0, DW_TAG_auto_variable), }; let align = cx.align_of(variable_type); @@ -210,8 +204,10 @@ impl DebugInfoBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> { align.bytes() as u32, ) }; - source_loc::set_debug_location(self, - InternalDebugLocation::new(scope_metadata, loc.line, loc.col.to_usize())); + source_loc::set_debug_location( + self, + InternalDebugLocation::new(scope_metadata, loc.line, loc.col.to_usize()), + ); unsafe { let debug_loc = llvm::LLVMGetCurrentDebugLocation(self.llbuilder); let instr = llvm::LLVMRustDIBuilderInsertDeclareAtEnd( @@ -221,7 +217,8 @@ impl DebugInfoBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> { addr_ops.as_ptr(), addr_ops.len() as c_uint, debug_loc, - self.llbb()); + self.llbb(), + ); llvm::LLVMSetInstDebugLocation(self.llbuilder, instr); } @@ -249,8 +246,7 @@ impl DebugInfoBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> { // Only function parameters and instructions are local to a function, // don't change the name of anything else (e.g. globals). let param_or_inst = unsafe { - llvm::LLVMIsAArgument(value).is_some() || - llvm::LLVMIsAInstruction(value).is_some() + llvm::LLVMIsAArgument(value).is_some() || llvm::LLVMIsAInstruction(value).is_some() }; if !param_or_inst { return; @@ -311,11 +307,8 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { // name if necessary. let generics = self.tcx().generics_of(enclosing_fn_def_id); let substs = instance.substs.truncate_to(self.tcx(), generics); - let template_parameters = get_template_parameters(self, - &generics, - substs, - file_metadata, - &mut name); + let template_parameters = + get_template_parameters(self, &generics, substs, file_metadata, &mut name); // Get the linkage_name, which is just the symbol name let linkage_name = mangled_name_of_instance(self, instance); @@ -358,7 +351,8 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { spflags, llfn, template_parameters, - None) + None, + ) }; // Initialize fn debug context (including scopes). @@ -366,7 +360,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { let null_scope = DebugScope { scope_metadata: None, file_start_pos: BytePos(0), - file_end_pos: BytePos(0) + file_end_pos: BytePos(0), }; let mut fn_debug_context = FunctionDebugContext { scopes: IndexVec::from_elem(null_scope, &mir.source_scopes), @@ -412,17 +406,21 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { let t = arg.layout.ty; let t = match t.kind { ty::Array(ct, _) - if (ct == cx.tcx.types.u8) || cx.layout_of(ct).is_zst() => { + if (ct == cx.tcx.types.u8) || cx.layout_of(ct).is_zst() => + { cx.tcx.mk_imm_ptr(ct) } - _ => t + _ => t, }; Some(type_metadata(cx, t, syntax_pos::DUMMY_SP)) })); } else { - signature.extend(fn_abi.args.iter().map(|arg| { - Some(type_metadata(cx, arg.layout.ty, syntax_pos::DUMMY_SP)) - })); + signature.extend( + fn_abi + .args + .iter() + .map(|arg| Some(type_metadata(cx, arg.layout.ty, syntax_pos::DUMMY_SP))), + ); } create_DIArray(DIB(cx), &signature[..]) @@ -448,9 +446,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { let actual_type = cx.tcx.normalize_erasing_regions(ParamEnv::reveal_all(), actual_type); // Add actual type name to <...> clause of function name - let actual_type_name = compute_debuginfo_type_name(cx.tcx(), - actual_type, - true); + let actual_type_name = compute_debuginfo_type_name(cx.tcx(), actual_type, true); name_to_append_suffix_to.push_str(&actual_type_name[..]); } name_to_append_suffix_to.push('>'); @@ -458,28 +454,32 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { // Again, only create type information if full debuginfo is enabled let template_params: Vec<_> = if cx.sess().opts.debuginfo == DebugInfo::Full { let names = get_parameter_names(cx, generics); - substs.iter().zip(names).filter_map(|(kind, name)| { - if let GenericArgKind::Type(ty) = kind.unpack() { - let actual_type = - cx.tcx.normalize_erasing_regions(ParamEnv::reveal_all(), ty); - let actual_type_metadata = - type_metadata(cx, actual_type, syntax_pos::DUMMY_SP); - let name = SmallCStr::new(&name.as_str()); - Some(unsafe { - Some(llvm::LLVMRustDIBuilderCreateTemplateTypeParameter( - DIB(cx), - None, - name.as_ptr(), - actual_type_metadata, - file_metadata, - 0, - 0, - )) - }) - } else { - None - } - }).collect() + substs + .iter() + .zip(names) + .filter_map(|(kind, name)| { + if let GenericArgKind::Type(ty) = kind.unpack() { + let actual_type = + cx.tcx.normalize_erasing_regions(ParamEnv::reveal_all(), ty); + let actual_type_metadata = + type_metadata(cx, actual_type, syntax_pos::DUMMY_SP); + let name = SmallCStr::new(&name.as_str()); + Some(unsafe { + Some(llvm::LLVMRustDIBuilderCreateTemplateTypeParameter( + DIB(cx), + None, + name.as_ptr(), + actual_type_metadata, + file_metadata, + 0, + 0, + )) + }) + } else { + None + } + }) + .collect() } else { vec![] }; @@ -487,12 +487,10 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { return create_DIArray(DIB(cx), &template_params[..]); } - fn get_parameter_names(cx: &CodegenCx<'_, '_>, - generics: &ty::Generics) - -> Vec<Symbol> { - let mut names = generics.parent.map_or(vec![], |def_id| { - get_parameter_names(cx, cx.tcx.generics_of(def_id)) - }); + fn get_parameter_names(cx: &CodegenCx<'_, '_>, generics: &ty::Generics) -> Vec<Symbol> { + let mut names = generics + .parent + .map_or(vec![], |def_id| get_parameter_names(cx, cx.tcx.generics_of(def_id))); names.extend(generics.params.iter().map(|param| param.name)); names } @@ -519,7 +517,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { ty::Adt(def, ..) if !def.is_box() => { Some(type_metadata(cx, impl_self_ty, syntax_pos::DUMMY_SP)) } - _ => None + _ => None, } } else { // For trait method impls we still use the "parallel namespace" @@ -529,33 +527,33 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> { }); self_type.unwrap_or_else(|| { - namespace::item_namespace(cx, DefId { - krate: instance.def_id().krate, - index: cx.tcx - .def_key(instance.def_id()) - .parent - .expect("get_containing_scope: missing parent?") - }) + namespace::item_namespace( + cx, + DefId { + krate: instance.def_id().krate, + index: cx + .tcx + .def_key(instance.def_id()) + .parent + .expect("get_containing_scope: missing parent?"), + }, + ) }) } } - fn create_vtable_metadata( - &self, - ty: Ty<'tcx>, - vtable: Self::Value, - ) { + fn create_vtable_metadata(&self, ty: Ty<'tcx>, vtable: Self::Value) { metadata::create_vtable_metadata(self, ty, vtable) } fn extend_scope_to_file( - &self, - scope_metadata: &'ll DIScope, - file: &syntax_pos::SourceFile, - defining_crate: CrateNum, - ) -> &'ll DILexicalBlock { - metadata::extend_scope_to_file(&self, scope_metadata, file, defining_crate) - } + &self, + scope_metadata: &'ll DIScope, + file: &syntax_pos::SourceFile, + defining_crate: CrateNum, + ) -> &'ll DILexicalBlock { + metadata::extend_scope_to_file(&self, scope_metadata, file, defining_crate) + } fn debuginfo_finalize(&self) { finalize(self) diff --git a/src/librustc_codegen_llvm/debuginfo/namespace.rs b/src/librustc_codegen_llvm/debuginfo/namespace.rs index 482bcf2aa58..77b47efd3dd 100644 --- a/src/librustc_codegen_llvm/debuginfo/namespace.rs +++ b/src/librustc_codegen_llvm/debuginfo/namespace.rs @@ -1,12 +1,12 @@ // Namespace Handling. use super::metadata::{unknown_file_metadata, UNKNOWN_LINE_NUMBER}; -use super::utils::{DIB, debug_context}; +use super::utils::{debug_context, DIB}; use rustc::ty::{self, Instance}; +use crate::common::CodegenCx; use crate::llvm; use crate::llvm::debuginfo::DIScope; -use crate::common::CodegenCx; use rustc::hir::def_id::DefId; use rustc::hir::map::DefPathData; @@ -16,8 +16,8 @@ pub fn mangled_name_of_instance<'a, 'tcx>( cx: &CodegenCx<'a, 'tcx>, instance: Instance<'tcx>, ) -> ty::SymbolName { - let tcx = cx.tcx; - tcx.symbol_name(instance) + let tcx = cx.tcx; + tcx.symbol_name(instance) } pub fn item_namespace(cx: &CodegenCx<'ll, '_>, def_id: DefId) -> &'ll DIScope { @@ -26,16 +26,13 @@ pub fn item_namespace(cx: &CodegenCx<'ll, '_>, def_id: DefId) -> &'ll DIScope { } let def_key = cx.tcx.def_key(def_id); - let parent_scope = def_key.parent.map(|parent| { - item_namespace(cx, DefId { - krate: def_id.krate, - index: parent - }) - }); + let parent_scope = def_key + .parent + .map(|parent| item_namespace(cx, DefId { krate: def_id.krate, index: parent })); let namespace_name = match def_key.disambiguated_data.data { DefPathData::CrateRoot => cx.tcx.crate_name(def_id.krate), - data => data.as_symbol() + data => data.as_symbol(), }; let namespace_name = SmallCStr::new(&namespace_name.as_str()); @@ -46,7 +43,8 @@ pub fn item_namespace(cx: &CodegenCx<'ll, '_>, def_id: DefId) -> &'ll DIScope { parent_scope, namespace_name.as_ptr(), unknown_file_metadata(cx), - UNKNOWN_LINE_NUMBER) + UNKNOWN_LINE_NUMBER, + ) }; debug_context(cx).namespace_map.borrow_mut().insert(def_id, scope); diff --git a/src/librustc_codegen_llvm/debuginfo/source_loc.rs b/src/librustc_codegen_llvm/debuginfo/source_loc.rs index 82183fa9bd7..5fb50e17236 100644 --- a/src/librustc_codegen_llvm/debuginfo/source_loc.rs +++ b/src/librustc_codegen_llvm/debuginfo/source_loc.rs @@ -1,17 +1,17 @@ use self::InternalDebugLocation::*; -use super::utils::{debug_context, span_start}; use super::metadata::UNKNOWN_COLUMN_NUMBER; +use super::utils::{debug_context, span_start}; use rustc_codegen_ssa::mir::debuginfo::FunctionDebugContext; +use crate::builder::Builder; use crate::llvm; use crate::llvm::debuginfo::DIScope; -use crate::builder::Builder; -use rustc_codegen_ssa::traits::*; use log::debug; +use rustc_codegen_ssa::traits::*; use libc::c_uint; -use syntax_pos::{Span, Pos}; +use syntax_pos::{Pos, Span}; /// Sets the current debug location at the beginning of the span. /// @@ -32,33 +32,25 @@ pub fn set_source_location<D>( set_debug_location(bx, dbg_loc); } - #[derive(Copy, Clone, PartialEq)] pub enum InternalDebugLocation<'ll> { KnownLocation { scope: &'ll DIScope, line: usize, col: usize }, - UnknownLocation + UnknownLocation, } impl InternalDebugLocation<'ll> { pub fn new(scope: &'ll DIScope, line: usize, col: usize) -> Self { - KnownLocation { - scope, - line, - col, - } + KnownLocation { scope, line, col } } } -pub fn set_debug_location( - bx: &Builder<'_, 'll, '_>, - debug_location: InternalDebugLocation<'ll> -) { +pub fn set_debug_location(bx: &Builder<'_, 'll, '_>, debug_location: InternalDebugLocation<'ll>) { let metadata_node = match debug_location { KnownLocation { scope, line, col } => { // For MSVC, set the column number to zero. // Otherwise, emit it. This mimics clang behaviour. // See discussion in https://github.com/rust-lang/rust/issues/42921 - let col_used = if bx.sess().target.target.options.is_like_msvc { + let col_used = if bx.sess().target.target.options.is_like_msvc { UNKNOWN_COLUMN_NUMBER } else { col as c_uint @@ -71,7 +63,8 @@ pub fn set_debug_location( line as c_uint, col_used, scope, - None)) + None, + )) } } UnknownLocation => { diff --git a/src/librustc_codegen_llvm/debuginfo/utils.rs b/src/librustc_codegen_llvm/debuginfo/utils.rs index c64e0d9806b..e77dab998d2 100644 --- a/src/librustc_codegen_llvm/debuginfo/utils.rs +++ b/src/librustc_codegen_llvm/debuginfo/utils.rs @@ -1,20 +1,19 @@ // Utility Functions. -use super::{CrateDebugContext}; use super::namespace::item_namespace; +use super::CrateDebugContext; use rustc::hir::def_id::DefId; use rustc::ty::DefIdTree; +use crate::common::CodegenCx; use crate::llvm; -use crate::llvm::debuginfo::{DIScope, DIBuilder, DIDescriptor, DIArray}; -use crate::common::{CodegenCx}; +use crate::llvm::debuginfo::{DIArray, DIBuilder, DIDescriptor, DIScope}; use rustc_codegen_ssa::traits::*; use syntax_pos::Span; -pub fn is_node_local_to_unit(cx: &CodegenCx<'_, '_>, def_id: DefId) -> bool -{ +pub fn is_node_local_to_unit(cx: &CodegenCx<'_, '_>, def_id: DefId) -> bool { // The is_local_to_unit flag indicates whether a function is local to the // current compilation unit (i.e., if it is *static* in the C-sense). The // *reachable* set should provide a good approximation of this, as it @@ -27,10 +26,7 @@ pub fn is_node_local_to_unit(cx: &CodegenCx<'_, '_>, def_id: DefId) -> bool } #[allow(non_snake_case)] -pub fn create_DIArray( - builder: &DIBuilder<'ll>, - arr: &[Option<&'ll DIDescriptor>], -) -> &'ll DIArray { +pub fn create_DIArray(builder: &DIBuilder<'ll>, arr: &[Option<&'ll DIDescriptor>]) -> &'ll DIArray { return unsafe { llvm::LLVMRustDIBuilderGetOrCreateArray(builder, arr.as_ptr(), arr.len() as u32) }; @@ -53,6 +49,5 @@ pub fn DIB(cx: &'a CodegenCx<'ll, '_>) -> &'a DIBuilder<'ll> { } 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?")) + item_namespace(cx, cx.tcx.parent(def_id).expect("get_namespace_for_item: missing parent?")) } |
