Skip to content

Commit 8c09e2b

Browse files
debuginfo: Big cleanup refactoring and support for foreign_item_fn.
1 parent f51d30d commit 8c09e2b

File tree

2 files changed

+101
-108
lines changed

2 files changed

+101
-108
lines changed

src/librustc/middle/trans/base.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@ fn fcx_has_nonzero_span(fcx: &FunctionContext) -> bool {
136136
}
137137
}
138138

139+
fn span_is_empty(opt_span: &Option<span>) -> bool {
140+
match *opt_span {
141+
None => true,
142+
Some(span) => *span.lo == 0 && *span.hi == 0
143+
}
144+
}
145+
139146
struct StatRecorder<'self> {
140147
ccx: @mut CrateContext,
141148
name: &'self str,
@@ -1623,6 +1630,13 @@ pub fn new_fn_ctxt_w_id(ccx: @mut CrateContext,
16231630
}
16241631
};
16251632
let uses_outptr = type_of::return_uses_outptr(ccx.tcx, substd_output_type);
1633+
1634+
let debug_context = if id != -1 && ccx.sess.opts.debuginfo && !span_is_empty(&sp) {
1635+
Some(debuginfo::create_function_debug_context(ccx, id, param_substs, llfndecl))
1636+
} else {
1637+
None
1638+
};
1639+
16261640
let fcx = @mut FunctionContext {
16271641
llfn: llfndecl,
16281642
llenv: unsafe {
@@ -1643,7 +1657,7 @@ pub fn new_fn_ctxt_w_id(ccx: @mut CrateContext,
16431657
span: sp,
16441658
path: path,
16451659
ccx: ccx,
1646-
debug_context: None,
1660+
debug_context: debug_context,
16471661
};
16481662
fcx.llenv = unsafe {
16491663
llvm::LLVMGetParam(llfndecl, fcx.env_arg_pos() as c_uint)
@@ -1880,10 +1894,6 @@ pub fn trans_closure(ccx: @mut CrateContext,
18801894
set_fixed_stack_segment(fcx.llfn);
18811895
}
18821896

1883-
if ccx.sess.opts.debuginfo && fcx_has_nonzero_span(fcx) {
1884-
debuginfo::create_function_metadata(fcx);
1885-
}
1886-
18871897
// Create the first basic block in the function and keep a handle on it to
18881898
// pass to finish_fn later.
18891899
let bcx_top = fcx.entry_bcx.unwrap();

0 commit comments

Comments
 (0)