diff options
| author | The Miri Cronjob Bot <miri@cron.bot> | 2025-09-20 05:00:06 +0000 |
|---|---|---|
| committer | The Miri Cronjob Bot <miri@cron.bot> | 2025-09-20 05:00:06 +0000 |
| commit | 340c6e76ec16aae2110596b8b3fa7f05fee7858e (patch) | |
| tree | e5f4a0c1b6c8c14eabab0b89b839f2f7fec53aa8 /compiler/rustc_codegen_llvm/src/common.rs | |
| parent | 88ceae98c57e17bf9923861d7c91319d7ca44f69 (diff) | |
| parent | 42ebba214b3c570761dc99f5fc1517ad092778ac (diff) | |
| download | rust-340c6e76ec16aae2110596b8b3fa7f05fee7858e.tar.gz rust-340c6e76ec16aae2110596b8b3fa7f05fee7858e.zip | |
Merge ref 'ec3867107526' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: ec38671075266e9cee0348701da2e133379e7c6c Filtered ref: ed8e25574abf50600d9d2fd61eda90708ccce6c2 Upstream diff: https://github.com/rust-lang/rust/compare/3f1552a273e43e15f6ed240d00e1efdd6a53e65e...ec38671075266e9cee0348701da2e133379e7c6c This merge was created using https://github.com/rust-lang/josh-sync.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/common.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/common.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_llvm/src/common.rs b/compiler/rustc_codegen_llvm/src/common.rs index 11b79a7fe68..aa2df46329f 100644 --- a/compiler/rustc_codegen_llvm/src/common.rs +++ b/compiler/rustc_codegen_llvm/src/common.rs @@ -108,6 +108,10 @@ impl<'ll, CX: Borrow<SCx<'ll>>> GenericCx<'ll, CX> { bytes_in_context(self.llcx(), bytes) } + pub(crate) fn null_terminate_const_bytes(&self, bytes: &[u8]) -> &'ll Value { + null_terminate_bytes_in_context(self.llcx(), bytes) + } + pub(crate) fn const_get_elt(&self, v: &'ll Value, idx: u64) -> &'ll Value { unsafe { let idx = c_uint::try_from(idx).expect("LLVMGetAggregateElement index overflow"); @@ -381,6 +385,16 @@ pub(crate) fn bytes_in_context<'ll>(llcx: &'ll llvm::Context, bytes: &[u8]) -> & } } +pub(crate) fn null_terminate_bytes_in_context<'ll>( + llcx: &'ll llvm::Context, + bytes: &[u8], +) -> &'ll Value { + unsafe { + let ptr = bytes.as_ptr() as *const c_char; + llvm::LLVMConstStringInContext2(llcx, ptr, bytes.len(), FALSE) + } +} + pub(crate) fn named_struct<'ll>(ty: &'ll Type, elts: &[&'ll Value]) -> &'ll Value { let len = c_uint::try_from(elts.len()).expect("LLVMConstStructInContext elements len overflow"); unsafe { llvm::LLVMConstNamedStruct(ty, elts.as_ptr(), len) } |
