about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrian Leibig <brian.leibig@gmail.com>2013-04-08 23:13:00 -0400
committerBrian Leibig <brian.leibig@gmail.com>2013-04-10 12:45:54 -0400
commit10d930d51ea6a00349c08b53ecf6ffb1ee514219 (patch)
treecc52520c908cd97b8cb6f7cea1a934b6b80c7d5b
parentcf22d749eb9717e1e5befa727db5a9f7c47e8f48 (diff)
downloadrust-10d930d51ea6a00349c08b53ecf6ffb1ee514219.tar.gz
rust-10d930d51ea6a00349c08b53ecf6ffb1ee514219.zip
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.
-rw-r--r--src/librustc/middle/trans/base.rs15
-rw-r--r--src/librustc/middle/trans/debuginfo.rs2
2 files changed, 13 insertions, 4 deletions
diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs
index 4faff086098..b8a14cb329b 100644
--- a/src/librustc/middle/trans/base.rs
+++ b/src/librustc/middle/trans/base.rs
@@ -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) +
@@ -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);
                         }
                     }
@@ -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);
         }
     }
@@ -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);
                       }
                   },
diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs
index c573529fbc2..31f89deff5d 100644
--- a/src/librustc/middle/trans/debuginfo.rs
+++ b/src/librustc/middle/trans/debuginfo.rs
@@ -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;