nhwn: use plain u32 in DebugLoc
This commit is contained in:
parent
f5aa1bceb9
commit
408d4027d0
3 changed files with 15 additions and 26 deletions
|
@ -1,4 +1,4 @@
|
||||||
use super::metadata::{file_metadata, UNKNOWN_COLUMN_NUMBER, UNKNOWN_LINE_NUMBER};
|
use super::metadata::file_metadata;
|
||||||
use super::utils::DIB;
|
use super::utils::DIB;
|
||||||
use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext};
|
use rustc_codegen_ssa::mir::debuginfo::{DebugScope, FunctionDebugContext};
|
||||||
use rustc_codegen_ssa::traits::*;
|
use rustc_codegen_ssa::traits::*;
|
||||||
|
@ -102,8 +102,8 @@ fn make_mir_scope(
|
||||||
DIB(cx),
|
DIB(cx),
|
||||||
parent_scope.dbg_scope.unwrap(),
|
parent_scope.dbg_scope.unwrap(),
|
||||||
file_metadata,
|
file_metadata,
|
||||||
loc.line.map_or(UNKNOWN_LINE_NUMBER, |n| n.get()),
|
loc.line,
|
||||||
loc.col.map_or(UNKNOWN_COLUMN_NUMBER, |n| n.get()),
|
loc.col,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1839,10 +1839,7 @@ impl<'tcx> VariantInfo<'_, 'tcx> {
|
||||||
.span;
|
.span;
|
||||||
if !span.is_dummy() {
|
if !span.is_dummy() {
|
||||||
let loc = cx.lookup_debug_loc(span.lo());
|
let loc = cx.lookup_debug_loc(span.lo());
|
||||||
return Some(SourceInfo {
|
return Some(SourceInfo { file: file_metadata(cx, &loc.file), line: loc.line });
|
||||||
file: file_metadata(cx, &loc.file),
|
|
||||||
line: loc.line.map_or(UNKNOWN_LINE_NUMBER, |n| n.get()),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -2481,7 +2478,7 @@ pub fn create_global_var_metadata(cx: &CodegenCx<'ll, '_>, def_id: DefId, global
|
||||||
let loc = cx.lookup_debug_loc(span.lo());
|
let loc = cx.lookup_debug_loc(span.lo());
|
||||||
(file_metadata(cx, &loc.file), loc.line)
|
(file_metadata(cx, &loc.file), loc.line)
|
||||||
} else {
|
} else {
|
||||||
(unknown_file_metadata(cx), None)
|
(unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER)
|
||||||
};
|
};
|
||||||
|
|
||||||
let is_local_to_unit = is_node_local_to_unit(cx, def_id);
|
let is_local_to_unit = is_node_local_to_unit(cx, def_id);
|
||||||
|
@ -2504,7 +2501,7 @@ pub fn create_global_var_metadata(cx: &CodegenCx<'ll, '_>, def_id: DefId, global
|
||||||
linkage_name.as_ptr().cast(),
|
linkage_name.as_ptr().cast(),
|
||||||
linkage_name.len(),
|
linkage_name.len(),
|
||||||
file_metadata,
|
file_metadata,
|
||||||
line_number.map_or(UNKNOWN_LINE_NUMBER, |n| n.get()),
|
line_number,
|
||||||
type_metadata,
|
type_metadata,
|
||||||
is_local_to_unit,
|
is_local_to_unit,
|
||||||
global,
|
global,
|
||||||
|
|
|
@ -38,7 +38,6 @@ use rustc_target::abi::{LayoutOf, Primitive, Size};
|
||||||
use libc::c_uint;
|
use libc::c_uint;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::num::NonZeroU32;
|
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
mod create_scope_map;
|
mod create_scope_map;
|
||||||
|
@ -225,9 +224,9 @@ pub struct DebugLoc {
|
||||||
/// Information about the original source file.
|
/// Information about the original source file.
|
||||||
pub file: Lrc<SourceFile>,
|
pub file: Lrc<SourceFile>,
|
||||||
/// The (1-based) line number.
|
/// The (1-based) line number.
|
||||||
pub line: Option<NonZeroU32>,
|
pub line: u32,
|
||||||
/// The (1-based) column number.
|
/// The (1-based) column number.
|
||||||
pub col: Option<NonZeroU32>,
|
pub col: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CodegenCx<'ll, '_> {
|
impl CodegenCx<'ll, '_> {
|
||||||
|
@ -244,16 +243,16 @@ impl CodegenCx<'ll, '_> {
|
||||||
let line = (line + 1) as u32;
|
let line = (line + 1) as u32;
|
||||||
let col = (pos - line_pos).to_u32() + 1;
|
let col = (pos - line_pos).to_u32() + 1;
|
||||||
|
|
||||||
(file, NonZeroU32::new(line), NonZeroU32::new(col))
|
(file, line, col)
|
||||||
}
|
}
|
||||||
Err(file) => (file, None, None),
|
Err(file) => (file, UNKNOWN_LINE_NUMBER, UNKNOWN_COLUMN_NUMBER),
|
||||||
};
|
};
|
||||||
|
|
||||||
// For MSVC, omit the column number.
|
// For MSVC, omit the column number.
|
||||||
// Otherwise, emit it. This mimics clang behaviour.
|
// Otherwise, emit it. This mimics clang behaviour.
|
||||||
// See discussion in https://github.com/rust-lang/rust/issues/42921
|
// See discussion in https://github.com/rust-lang/rust/issues/42921
|
||||||
if self.sess().target.is_like_msvc {
|
if self.sess().target.is_like_msvc {
|
||||||
DebugLoc { file, line, col: None }
|
DebugLoc { file, line, col: UNKNOWN_COLUMN_NUMBER }
|
||||||
} else {
|
} else {
|
||||||
DebugLoc { file, line, col }
|
DebugLoc { file, line, col }
|
||||||
}
|
}
|
||||||
|
@ -359,9 +358,9 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
linkage_name.as_ptr().cast(),
|
linkage_name.as_ptr().cast(),
|
||||||
linkage_name.len(),
|
linkage_name.len(),
|
||||||
file_metadata,
|
file_metadata,
|
||||||
loc.line.map_or(UNKNOWN_LINE_NUMBER, |n| n.get()),
|
loc.line,
|
||||||
function_type_metadata,
|
function_type_metadata,
|
||||||
scope_line.map_or(UNKNOWN_LINE_NUMBER, |n| n.get()),
|
scope_line,
|
||||||
flags,
|
flags,
|
||||||
spflags,
|
spflags,
|
||||||
maybe_definition_llfn,
|
maybe_definition_llfn,
|
||||||
|
@ -551,14 +550,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
) -> &'ll DILocation {
|
) -> &'ll DILocation {
|
||||||
let DebugLoc { line, col, .. } = self.lookup_debug_loc(span.lo());
|
let DebugLoc { line, col, .. } = self.lookup_debug_loc(span.lo());
|
||||||
|
|
||||||
unsafe {
|
unsafe { llvm::LLVMRustDIBuilderCreateDebugLocation(line, col, scope, inlined_at) }
|
||||||
llvm::LLVMRustDIBuilderCreateDebugLocation(
|
|
||||||
line.map_or(UNKNOWN_LINE_NUMBER, |n| n.get()),
|
|
||||||
col.map_or(UNKNOWN_COLUMN_NUMBER, |n| n.get()),
|
|
||||||
scope,
|
|
||||||
inlined_at,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_vtable_metadata(&self, ty: Ty<'tcx>, vtable: Self::Value) {
|
fn create_vtable_metadata(&self, ty: Ty<'tcx>, vtable: Self::Value) {
|
||||||
|
@ -607,7 +599,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
name.as_ptr().cast(),
|
name.as_ptr().cast(),
|
||||||
name.len(),
|
name.len(),
|
||||||
file_metadata,
|
file_metadata,
|
||||||
loc.line.map_or(UNKNOWN_LINE_NUMBER, |n| n.get()),
|
loc.line,
|
||||||
type_metadata,
|
type_metadata,
|
||||||
true,
|
true,
|
||||||
DIFlags::FlagZero,
|
DIFlags::FlagZero,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue