Skip to content

debuginfo: Don't crash when encountering global variable with unknown source span #15719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/librustc/middle/trans/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -798,15 +798,16 @@ pub fn create_global_var_metadata(cx: &CrateContext,
var_item).as_slice())
};

let filename = span_start(cx, span).file.name.clone();
let file_metadata = file_metadata(cx, filename.as_slice());
let (file_metadata, line_number) = if span != codemap::DUMMY_SP {
let loc = span_start(cx, span);
(file_metadata(cx, loc.file.name.as_slice()), loc.line as c_uint)
} else {
(UNKNOWN_FILE_METADATA, UNKNOWN_LINE_NUMBER)
};

let is_local_to_unit = is_node_local_to_unit(cx, node_id);
let loc = span_start(cx, span);

let variable_type = ty::node_id_to_type(cx.tcx(), node_id);
let type_metadata = type_metadata(cx, variable_type, span);

let namespace_node = namespace_for_item(cx, ast_util::local_def(node_id));
let var_name = token::get_ident(ident).get().to_string();
let linkage_name =
Expand All @@ -821,7 +822,7 @@ pub fn create_global_var_metadata(cx: &CrateContext,
var_name,
linkage_name,
file_metadata,
loc.line as c_uint,
line_number,
type_metadata,
is_local_to_unit,
global,
Expand Down