Skip to content

Commit

Permalink
Prevent debug info generation of zero-span nodes
Browse files Browse the repository at this point in the history
If a node has a (0, 0) span, it was not in the source, so debug symbols should not be generated for it.
  • Loading branch information
bleibig committed Apr 10, 2013
1 parent cf22d74 commit 10d930d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/librustc/middle/trans/base.rs
Expand Up @@ -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,
end: time::Timespec) {
let elapsed = 1000 * ((end.sec - start.sec) as int) +
Expand Down Expand Up @@ -1158,7 +1165,8 @@ pub fn trans_stmt(cx: block, s: ast::stmt) -> block {
ast::decl_local(ref locals) => {
for locals.each |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);
}
}
Expand Down Expand Up @@ -1738,7 +1746,7 @@ pub fn copy_args_to_allocas(fcx: fn_ctxt,

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);
}
}
Expand Down Expand Up @@ -1861,7 +1869,8 @@ pub fn trans_fn(ccx: @CrateContext,
trans_closure(ccx, path, decl, body, llfndecl, ty_self,
param_substs, id, impl_id,
|fcx| {
if ccx.sess.opts.extra_debuginfo {
if ccx.sess.opts.extra_debuginfo
&& fcx_has_nonzero_span(fcx) {
debuginfo::create_function(fcx);
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/debuginfo.rs
Expand Up @@ -946,7 +946,7 @@ pub fn create_arg(bcx: block, arg: ast::arg, sp: 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;
}
let cm = cx.sess().codemap;
Expand Down

0 comments on commit 10d930d

Please sign in to comment.