Pass LLVM string attributes as string slices
This commit is contained in:
parent
08504c64aa
commit
926bf1a371
5 changed files with 47 additions and 43 deletions
|
@ -47,12 +47,28 @@ pub fn AddCallSiteAttributes<'ll>(
|
|||
}
|
||||
}
|
||||
|
||||
pub fn CreateAttrStringValue<'ll>(llcx: &'ll Context, attr: &CStr, value: &CStr) -> &'ll Attribute {
|
||||
unsafe { LLVMRustCreateAttrStringValue(llcx, attr.as_ptr(), value.as_ptr()) }
|
||||
pub fn CreateAttrStringValue<'ll>(llcx: &'ll Context, attr: &str, value: &str) -> &'ll Attribute {
|
||||
unsafe {
|
||||
LLVMCreateStringAttribute(
|
||||
llcx,
|
||||
attr.as_ptr().cast(),
|
||||
attr.len().try_into().unwrap(),
|
||||
value.as_ptr().cast(),
|
||||
value.len().try_into().unwrap(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn CreateAttrString<'ll>(llcx: &'ll Context, attr: &CStr) -> &'ll Attribute {
|
||||
unsafe { LLVMRustCreateAttrStringValue(llcx, attr.as_ptr(), std::ptr::null()) }
|
||||
pub fn CreateAttrString<'ll>(llcx: &'ll Context, attr: &str) -> &'ll Attribute {
|
||||
unsafe {
|
||||
LLVMCreateStringAttribute(
|
||||
llcx,
|
||||
attr.as_ptr().cast(),
|
||||
attr.len().try_into().unwrap(),
|
||||
std::ptr::null(),
|
||||
0,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn CreateAlignmentAttr(llcx: &Context, bytes: u64) -> &Attribute {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue