Skip to content

Commit

Permalink
debuginfo: Use same behavior as Clang for calculating scope_line para…
Browse files Browse the repository at this point in the history
…meter when creating function DIEs.
  • Loading branch information
michaelwoerister committed Dec 16, 2013
1 parent 45e472a commit 69f4bf7
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/librustc/middle/trans/debuginfo.rs
Expand Up @@ -651,7 +651,8 @@ pub fn create_function_debug_context(cx: &mut CrateContext,
(function_name.clone(), file_metadata)
};

let scope_line = get_scope_line(cx, top_level_block, loc.line);
// Clang sets this parameter to the opening brace of the function's block, so let's do this too.
let scope_line = span_start(cx, top_level_block.span).line;

let fn_metadata = function_name.with_c_str(|function_name| {
linkage_name.with_c_str(|linkage_name| {
Expand Down Expand Up @@ -840,21 +841,6 @@ pub fn create_function_debug_context(cx: &mut CrateContext,

return create_DIArray(DIB(cx), template_params);
}

fn get_scope_line(cx: &CrateContext,
top_level_block: &ast::Block,
default: uint)
-> uint {
match *top_level_block {
ast::Block { stmts: ref statements, .. } if statements.len() > 0 => {
span_start(cx, statements[0].span).line
}
ast::Block { expr: Some(@ref expr), .. } => {
span_start(cx, expr.span).line
}
_ => default
}
}
}

//=-------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 69f4bf7

Please sign in to comment.