1
Fork 0

Prevent debug info generation of zero-span nodes

If a node has a (0, 0) span, it was not in the source, so debug symbols should not be generated for it.
This commit is contained in:
Brian Leibig 2013-04-08 23:13:00 -04:00
parent cf22d749eb
commit 10d930d51e
2 changed files with 13 additions and 4 deletions

View file

@ -131,6 +131,13 @@ impl get_insn_ctxt for fn_ctxt {
} }
} }
fn fcx_has_nonzero_span(fcx: fn_ctxt) -> bool {
match fcx.span {
None => true,
Some(span) => *span.lo != 0 || *span.hi != 0
}
}
pub fn log_fn_time(ccx: @CrateContext, +name: ~str, start: time::Timespec, pub fn log_fn_time(ccx: @CrateContext, +name: ~str, start: time::Timespec,
end: time::Timespec) { end: time::Timespec) {
let elapsed = 1000 * ((end.sec - start.sec) as int) + let elapsed = 1000 * ((end.sec - start.sec) as int) +
@ -1158,7 +1165,8 @@ pub fn trans_stmt(cx: block, s: ast::stmt) -> block {
ast::decl_local(ref locals) => { ast::decl_local(ref locals) => {
for locals.each |local| { for locals.each |local| {
bcx = init_local(bcx, *local); bcx = init_local(bcx, *local);
if cx.sess().opts.extra_debuginfo { if cx.sess().opts.extra_debuginfo
&& fcx_has_nonzero_span(bcx.fcx) {
debuginfo::create_local_var(bcx, *local); debuginfo::create_local_var(bcx, *local);
} }
} }
@ -1738,7 +1746,7 @@ pub fn copy_args_to_allocas(fcx: fn_ctxt,
fcx.llargs.insert(arg_id, local_mem(llarg)); fcx.llargs.insert(arg_id, local_mem(llarg));
if fcx.ccx.sess.opts.extra_debuginfo { if fcx.ccx.sess.opts.extra_debuginfo && fcx_has_nonzero_span(fcx) {
debuginfo::create_arg(bcx, args[arg_n], args[arg_n].ty.span); debuginfo::create_arg(bcx, args[arg_n], args[arg_n].ty.span);
} }
} }
@ -1861,7 +1869,8 @@ pub fn trans_fn(ccx: @CrateContext,
trans_closure(ccx, path, decl, body, llfndecl, ty_self, trans_closure(ccx, path, decl, body, llfndecl, ty_self,
param_substs, id, impl_id, param_substs, id, impl_id,
|fcx| { |fcx| {
if ccx.sess.opts.extra_debuginfo { if ccx.sess.opts.extra_debuginfo
&& fcx_has_nonzero_span(fcx) {
debuginfo::create_function(fcx); debuginfo::create_function(fcx);
} }
}, },

View file

@ -946,7 +946,7 @@ pub fn create_arg(bcx: block, arg: ast::arg, sp: span)
} }
pub fn update_source_pos(cx: block, s: span) { pub fn update_source_pos(cx: block, s: span) {
if !cx.sess().opts.debuginfo { if !cx.sess().opts.debuginfo || (*s.lo == 0 && *s.hi == 0) {
return; return;
} }
let cm = cx.sess().codemap; let cm = cx.sess().codemap;