rustc_codegen_llvm: create DIFile
s from just SourceFile
s.
This commit is contained in:
parent
2bfb462b58
commit
9d57c417fc
6 changed files with 21 additions and 54 deletions
|
@ -76,7 +76,7 @@ fn make_mir_scope(
|
|||
}
|
||||
|
||||
let loc = cx.lookup_debug_loc(scope_data.span.lo());
|
||||
let file_metadata = file_metadata(cx, &loc.file, debug_context.defining_crate);
|
||||
let file_metadata = file_metadata(cx, &loc.file);
|
||||
|
||||
let scope_metadata = unsafe {
|
||||
Some(llvm::LLVMRustDIBuilderCreateLexicalBlock(
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
//! utilizing a cache. The way to get a shared metadata node when needed is
|
||||
//! thus to just call the corresponding function in this module:
|
||||
//!
|
||||
//! let file_metadata = file_metadata(crate_context, path);
|
||||
//! let file_metadata = file_metadata(cx, file);
|
||||
//!
|
||||
//! The function will take care of probing the cache for an existing node for
|
||||
//! that exact file path.
|
||||
|
|
|
@ -26,7 +26,7 @@ use rustc_data_structures::fx::FxHashMap;
|
|||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_fs_util::path_to_c_string;
|
||||
use rustc_hir::def::CtorKind;
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_middle::ich::NodeIdHashingMode;
|
||||
use rustc_middle::mir::interpret::truncate;
|
||||
|
@ -760,16 +760,12 @@ fn hex_encode(data: &[u8]) -> String {
|
|||
hex_string
|
||||
}
|
||||
|
||||
pub fn file_metadata(
|
||||
cx: &CodegenCx<'ll, '_>,
|
||||
source_file: &SourceFile,
|
||||
defining_crate: CrateNum,
|
||||
) -> &'ll DIFile {
|
||||
debug!("file_metadata: file_name: {}, defining_crate: {}", source_file.name, defining_crate);
|
||||
pub fn file_metadata(cx: &CodegenCx<'ll, '_>, source_file: &SourceFile) -> &'ll DIFile {
|
||||
debug!("file_metadata: file_name: {}", source_file.name);
|
||||
|
||||
let hash = Some(&source_file.src_hash);
|
||||
let file_name = Some(source_file.name.to_string());
|
||||
let directory = if defining_crate == LOCAL_CRATE {
|
||||
let directory = if source_file.is_real_file() && !source_file.is_imported() {
|
||||
Some(cx.sess().working_dir.0.to_string_lossy().to_string())
|
||||
} else {
|
||||
// If the path comes from an upstream crate we assume it has been made
|
||||
|
@ -1835,7 +1831,7 @@ impl<'tcx> VariantInfo<'_, 'tcx> {
|
|||
if !span.is_dummy() {
|
||||
let loc = cx.lookup_debug_loc(span.lo());
|
||||
return Some(SourceInfo {
|
||||
file: file_metadata(cx, &loc.file, def_id.krate),
|
||||
file: file_metadata(cx, &loc.file),
|
||||
line: loc.line.unwrap_or(UNKNOWN_LINE_NUMBER),
|
||||
});
|
||||
}
|
||||
|
@ -2474,7 +2470,7 @@ pub fn create_global_var_metadata(cx: &CodegenCx<'ll, '_>, def_id: DefId, global
|
|||
|
||||
let (file_metadata, line_number) = if !span.is_dummy() {
|
||||
let loc = cx.lookup_debug_loc(span.lo());
|
||||
(file_metadata(cx, &loc.file, LOCAL_CRATE), loc.line)
|
||||
(file_metadata(cx, &loc.file), loc.line)
|
||||
} else {
|
||||
(unknown_file_metadata(cx), None)
|
||||
};
|
||||
|
@ -2576,9 +2572,8 @@ pub fn create_vtable_metadata(cx: &CodegenCx<'ll, 'tcx>, ty: Ty<'tcx>, vtable: &
|
|||
pub fn extend_scope_to_file(
|
||||
cx: &CodegenCx<'ll, '_>,
|
||||
scope_metadata: &'ll DIScope,
|
||||
file: &rustc_span::SourceFile,
|
||||
defining_crate: CrateNum,
|
||||
file: &SourceFile,
|
||||
) -> &'ll DILexicalBlock {
|
||||
let file_metadata = file_metadata(cx, &file, defining_crate);
|
||||
let file_metadata = file_metadata(cx, file);
|
||||
unsafe { llvm::LLVMRustDIBuilderCreateLexicalBlockFile(DIB(cx), scope_metadata, file_metadata) }
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ use rustc_codegen_ssa::debuginfo::type_names;
|
|||
use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext, VariableKind};
|
||||
use rustc_codegen_ssa::traits::*;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::{DefId, DefIdMap, LOCAL_CRATE};
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::ty::layout::HasTyCtxt;
|
||||
|
@ -246,7 +246,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||
let def_id = instance.def_id();
|
||||
let containing_scope = get_containing_scope(self, instance);
|
||||
let loc = self.lookup_debug_loc(span.lo());
|
||||
let file_metadata = file_metadata(self, &loc.file, def_id.krate);
|
||||
let file_metadata = file_metadata(self, &loc.file);
|
||||
|
||||
let function_type_metadata = unsafe {
|
||||
let fn_signature = get_function_signature(self, fn_abi);
|
||||
|
@ -318,10 +318,8 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||
file_start_pos: BytePos(0),
|
||||
file_end_pos: BytePos(0),
|
||||
};
|
||||
let mut fn_debug_context = FunctionDebugContext {
|
||||
scopes: IndexVec::from_elem(null_scope, &mir.source_scopes),
|
||||
defining_crate: def_id.krate,
|
||||
};
|
||||
let mut fn_debug_context =
|
||||
FunctionDebugContext { scopes: IndexVec::from_elem(null_scope, &mir.source_scopes) };
|
||||
|
||||
// Fill in all the scopes, with the information from the MIR body.
|
||||
compute_mir_scopes(self, mir, fn_metadata, &mut fn_debug_context);
|
||||
|
@ -509,9 +507,8 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||
&self,
|
||||
scope_metadata: &'ll DIScope,
|
||||
file: &rustc_span::SourceFile,
|
||||
defining_crate: CrateNum,
|
||||
) -> &'ll DILexicalBlock {
|
||||
metadata::extend_scope_to_file(&self, scope_metadata, file, defining_crate)
|
||||
metadata::extend_scope_to_file(&self, scope_metadata, file)
|
||||
}
|
||||
|
||||
fn debuginfo_finalize(&self) {
|
||||
|
@ -522,7 +519,6 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||
// names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.).
|
||||
fn create_dbg_var(
|
||||
&self,
|
||||
dbg_context: &FunctionDebugContext<&'ll DIScope>,
|
||||
variable_name: Symbol,
|
||||
variable_type: Ty<'tcx>,
|
||||
scope_metadata: &'ll DIScope,
|
||||
|
@ -530,7 +526,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||
span: Span,
|
||||
) -> &'ll DIVariable {
|
||||
let loc = self.lookup_debug_loc(span.lo());
|
||||
let file_metadata = file_metadata(self, &loc.file, dbg_context.defining_crate);
|
||||
let file_metadata = file_metadata(self, &loc.file);
|
||||
|
||||
let type_metadata = type_metadata(self, variable_type, span);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue