Add field to FunctionCx for passing caller location.
This commit is contained in:
parent
d47043b1c9
commit
f1d942b371
|
@ -1004,14 +1004,18 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
bx: &mut Bx,
|
||||
span: Span,
|
||||
) -> OperandRef<'tcx, Bx::Value> {
|
||||
let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
|
||||
let caller = bx.tcx().sess.source_map().lookup_char_pos(topmost.lo());
|
||||
let const_loc = bx.tcx().const_caller_location((
|
||||
Symbol::intern(&caller.file.name.to_string()),
|
||||
caller.line as u32,
|
||||
caller.col_display as u32 + 1,
|
||||
));
|
||||
OperandRef::from_const(bx, const_loc)
|
||||
if let Some(l) = self.caller_location {
|
||||
bx.load_operand(l)
|
||||
} else {
|
||||
let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
|
||||
let caller = bx.tcx().sess.source_map().lookup_char_pos(topmost.lo());
|
||||
let const_loc = bx.tcx().const_caller_location((
|
||||
Symbol::intern(&caller.file.name.to_string()),
|
||||
caller.line as u32,
|
||||
caller.col_display as u32 + 1,
|
||||
));
|
||||
OperandRef::from_const(bx, const_loc)
|
||||
}
|
||||
}
|
||||
|
||||
fn get_personality_slot(
|
||||
|
|
|
@ -77,6 +77,9 @@ pub struct FunctionCx<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> {
|
|||
/// All `VarDebuginfo` from the MIR body, partitioned by `Local`.
|
||||
/// This is `None` if no variable debuginfo/names are needed.
|
||||
per_local_var_debug_info: Option<IndexVec<mir::Local, Vec<&'tcx mir::VarDebugInfo<'tcx>>>>,
|
||||
|
||||
/// Caller location propagated if this function has `#[track_caller]`.
|
||||
caller_location: Option<PlaceRef<'tcx, Bx::Value>>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
|
@ -172,6 +175,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
|||
locals: IndexVec::new(),
|
||||
debug_context,
|
||||
per_local_var_debug_info: debuginfo::per_local_var_debug_info(cx.tcx(), mir_body),
|
||||
caller_location: None,
|
||||
};
|
||||
|
||||
let memory_locals = analyze::non_ssa_locals(&fx);
|
||||
|
|
Loading…
Reference in New Issue