diff options
| author | Josh Stone <jistone@redhat.com> | 2019-12-04 12:00:28 -0800 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2019-12-04 12:00:28 -0800 |
| commit | 16d21783d63c9ff89742ab83c2d02d25307c262c (patch) | |
| tree | 9773f3d16139d9e5f38b839df7372a5aad1aa8e4 /src/librustc_codegen_llvm/debuginfo | |
| parent | c4f130493564b23e78628af25201e7e2260849f6 (diff) | |
| download | rust-16d21783d63c9ff89742ab83c2d02d25307c262c.tar.gz rust-16d21783d63c9ff89742ab83c2d02d25307c262c.zip | |
Migrate to LLVM{Get,Set}ValueName2
The deprecated `LLVM{Get,Set}ValueName` only work with NUL-terminated
strings, but the `2` variants use explicit lengths, which fits better
with Rust strings and slices. We now use these in new helper functions
`llvm::{get,set}_value_name` that convert to/from `&[u8]`.
Diffstat (limited to 'src/librustc_codegen_llvm/debuginfo')
| -rw-r--r-- | src/librustc_codegen_llvm/debuginfo/mod.rs | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/src/librustc_codegen_llvm/debuginfo/mod.rs b/src/librustc_codegen_llvm/debuginfo/mod.rs index c2359a2fe6d..a3782ecd92d 100644 --- a/src/librustc_codegen_llvm/debuginfo/mod.rs +++ b/src/librustc_codegen_llvm/debuginfo/mod.rs @@ -32,7 +32,7 @@ use rustc_codegen_ssa::mir::debuginfo::{FunctionDebugContext, DebugScope, use libc::c_uint; use std::cell::RefCell; -use std::ffi::{CStr, CString}; +use std::ffi::CString; use smallvec::SmallVec; use syntax_pos::{self, BytePos, Span, Pos}; @@ -255,23 +255,11 @@ impl DebugInfoBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> { return; } - let old_name = unsafe { - CStr::from_ptr(llvm::LLVMGetValueName(value)) - }; - match old_name.to_str() { - Ok("") => {} - Ok(_) => { - // Avoid replacing the name if it already exists. - // While we could combine the names somehow, it'd - // get noisy quick, and the usefulness is dubious. - return; - } - Err(_) => return, - } - - let cname = SmallCStr::new(name); - unsafe { - llvm::LLVMSetValueName(value, cname.as_ptr()); + // Avoid replacing the name if it already exists. + // While we could combine the names somehow, it'd + // get noisy quick, and the usefulness is dubious. + if llvm::get_value_name(value).is_empty() { + llvm::set_value_name(value, name.as_bytes()); } } } |
