Skip to content

Commit

Permalink
debuginfo: Set correct source position for function calls.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwoerister committed Dec 16, 2013
1 parent b0100c5 commit 91efb2a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
22 changes: 19 additions & 3 deletions src/librustc/middle/trans/base.rs
Expand Up @@ -875,8 +875,11 @@ pub fn trans_external_path(ccx: &mut CrateContext, did: ast::DefId, t: ty::t) ->
}
}
pub fn invoke(bcx: @mut Block, llfn: ValueRef, llargs: ~[ValueRef],
attributes: &[(uint, lib::llvm::Attribute)])
pub fn invoke(bcx: @mut Block,
llfn: ValueRef,
llargs: ~[ValueRef],
attributes: &[(uint, lib::llvm::Attribute)],
call_info: Option<NodeInfo>)
-> (ValueRef, @mut Block) {
let _icx = push_ctxt("invoke_");
if bcx.unreachable {
Expand All @@ -899,11 +902,18 @@ pub fn invoke(bcx: @mut Block, llfn: ValueRef, llargs: ~[ValueRef],
}
}
let normal_bcx = sub_block(bcx, "normal return");
let landing_pad = get_landing_pad(bcx);

match call_info {
Some(info) => debuginfo::set_source_location(bcx.fcx, info.id, info.span),
None => debuginfo::clear_source_location(bcx.fcx)
};

let llresult = Invoke(bcx,
llfn,
llargs,
normal_bcx.llbb,
get_landing_pad(bcx),
landing_pad,
attributes);
return (llresult, normal_bcx);
} else {
Expand All @@ -913,6 +923,12 @@ pub fn invoke(bcx: @mut Block, llfn: ValueRef, llargs: ~[ValueRef],
debug!("arg: {}", llarg);
}
}

match call_info {
Some(info) => debuginfo::set_source_location(bcx.fcx, info.id, info.span),
None => debuginfo::clear_source_location(bcx.fcx)
};

let llresult = Call(bcx, llfn, llargs, attributes);
return (llresult, bcx);
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/callee.rs
Expand Up @@ -697,7 +697,7 @@ pub fn trans_call_inner(in_cx: @mut Block,
}

// Invoke the actual rust fn and update bcx/llresult.
let (llret, b) = base::invoke(bcx, llfn, llargs, attrs);
let (llret, b) = base::invoke(bcx, llfn, llargs, attrs, call_info);
bcx = b;
llresult = llret;

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/glue.rs
Expand Up @@ -429,7 +429,7 @@ pub fn trans_struct_drop(bcx: @mut Block, t: ty::t, v0: ValueRef, dtor_did: ast:
add_clean(bcx, llfld_a, fld.mt.ty);
}

let (_, bcx) = invoke(bcx, dtor_addr, args, []);
let (_, bcx) = invoke(bcx, dtor_addr, args, [], None);
bcx
})
}
Expand Down

0 comments on commit 91efb2a

Please sign in to comment.