Rollup merge of #51980 - est31:columns, r=alexcrichton

Emit column info in debuginfo for non msvc like targets

Fixes #42921 everywhere except MSVC. This mimics clang behaviour.
This commit is contained in:
Pietro Albini 2018-07-03 11:31:09 +02:00 committed by GitHub
commit 45cd78a4cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -81,16 +81,22 @@ impl InternalDebugLocation {
pub fn set_debug_location(bx: &Builder, debug_location: InternalDebugLocation) {
let metadata_node = match debug_location {
KnownLocation { scope, line, .. } => {
// Always set the column to zero like Clang and GCC
let col = UNKNOWN_COLUMN_NUMBER;
KnownLocation { scope, line, col } => {
// For MSVC, set the column number to zero.
// Otherwise, emit it. This mimics clang behaviour.
// See discussion in https://github.com/rust-lang/rust/issues/42921
let col_used = if bx.cx.sess().target.target.options.is_like_msvc {
UNKNOWN_COLUMN_NUMBER
} else {
col as c_uint
};
debug!("setting debug location to {} {}", line, col);
unsafe {
llvm::LLVMRustDIBuilderCreateDebugLocation(
debug_context(bx.cx).llcontext,
line as c_uint,
col as c_uint,
col_used,
scope,
ptr::null_mut())
}