diff options
| author | Yuki OKUSHI <huyuumi.dev@gmail.com> | 2019-03-30 21:37:02 +0900 |
|---|---|---|
| committer | Yuki OKUSHI <huyuumi.dev@gmail.com> | 2019-03-30 21:37:02 +0900 |
| commit | 77774e4e960e6b65ddb95b087772c6d2ad6c3009 (patch) | |
| tree | b2306372d41a47c7ea2941ddfece0c9d8c3ebea8 | |
| parent | 3281248b88262687fcf34b2404cece968bcf837c (diff) | |
| download | rust-77774e4e960e6b65ddb95b087772c6d2ad6c3009.tar.gz rust-77774e4e960e6b65ddb95b087772c6d2ad6c3009.zip | |
Use CString
| -rw-r--r-- | src/librustc_codegen_llvm/attributes.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/librustc_codegen_llvm/attributes.rs b/src/librustc_codegen_llvm/attributes.rs index 9aaad60cd6d..77fa34e74dd 100644 --- a/src/librustc_codegen_llvm/attributes.rs +++ b/src/librustc_codegen_llvm/attributes.rs @@ -80,14 +80,12 @@ pub fn set_instrument_function(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) { // The function name varies on platforms. // See test/CodeGen/mcount.c in clang. - use std::ffi::CStr; - let target_mcount = format!("{}{}", - &cx.sess().target.target.options.target_mcount, "\0"); - let mcount_name = CStr::from_bytes_with_nul(target_mcount.as_bytes()).unwrap(); + let mcount_name = CString::new( + cx.sess().target.target.options.target_mcount.as_str().as_bytes()).unwrap(); llvm::AddFunctionAttrStringValue( llfn, llvm::AttributePlace::Function, - const_cstr!("instrument-function-entry-inlined"), mcount_name); + const_cstr!("instrument-function-entry-inlined"), &mcount_name); } } |
