Skip to content

Commit 45cd78a

Browse files
authored
Rollup merge of rust-lang#51980 - est31:columns, r=alexcrichton
Emit column info in debuginfo for non msvc like targets Fixes rust-lang#42921 everywhere except MSVC. This mimics clang behaviour.
2 parents f91b02b + 3779a4c commit 45cd78a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/librustc_codegen_llvm/debuginfo/source_loc.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,22 @@ impl InternalDebugLocation {
8181

8282
pub fn set_debug_location(bx: &Builder, debug_location: InternalDebugLocation) {
8383
let metadata_node = match debug_location {
84-
KnownLocation { scope, line, .. } => {
85-
// Always set the column to zero like Clang and GCC
86-
let col = UNKNOWN_COLUMN_NUMBER;
84+
KnownLocation { scope, line, col } => {
85+
// For MSVC, set the column number to zero.
86+
// Otherwise, emit it. This mimics clang behaviour.
87+
// See discussion in https://github.com/rust-lang/rust/issues/42921
88+
let col_used = if bx.cx.sess().target.target.options.is_like_msvc {
89+
UNKNOWN_COLUMN_NUMBER
90+
} else {
91+
col as c_uint
92+
};
8793
debug!("setting debug location to {} {}", line, col);
8894

8995
unsafe {
9096
llvm::LLVMRustDIBuilderCreateDebugLocation(
9197
debug_context(bx.cx).llcontext,
9298
line as c_uint,
93-
col as c_uint,
99+
col_used,
94100
scope,
95101
ptr::null_mut())
96102
}

0 commit comments

Comments
 (0)