Avoid a bunch of unnecessary unsafe blocks in cg_llvm
This commit is contained in:
@@ -1009,7 +1009,7 @@ unsafe extern "C" {
|
||||
ModuleID: *const c_char,
|
||||
C: &Context,
|
||||
) -> &Module;
|
||||
pub(crate) fn LLVMCloneModule(M: &Module) -> &Module;
|
||||
pub(crate) safe fn LLVMCloneModule(M: &Module) -> &Module;
|
||||
|
||||
/// Data layout. See Module::getDataLayout.
|
||||
pub(crate) fn LLVMGetDataLayoutStr(M: &Module) -> *const c_char;
|
||||
@@ -1179,7 +1179,7 @@ unsafe extern "C" {
|
||||
pub(crate) fn LLVMIsThreadLocal(GlobalVar: &Value) -> Bool;
|
||||
pub(crate) fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
|
||||
pub(crate) fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
|
||||
pub(crate) fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
|
||||
pub(crate) safe fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
|
||||
pub(crate) safe fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool);
|
||||
|
||||
// Operations on attributes
|
||||
@@ -1718,7 +1718,7 @@ unsafe extern "C" {
|
||||
|
||||
pub(crate) safe fn LLVMMetadataAsValue<'a>(C: &'a Context, MD: &'a Metadata) -> &'a Value;
|
||||
|
||||
pub(crate) fn LLVMSetUnnamedAddress(Global: &Value, UnnamedAddr: UnnamedAddr);
|
||||
pub(crate) safe fn LLVMSetUnnamedAddress(Global: &Value, UnnamedAddr: UnnamedAddr);
|
||||
|
||||
pub(crate) fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>;
|
||||
|
||||
|
||||
@@ -217,10 +217,8 @@ pub(crate) fn SetUniqueComdat(llmod: &Module, val: &Value) {
|
||||
set_comdat(llmod, val, &name);
|
||||
}
|
||||
|
||||
pub(crate) fn SetUnnamedAddress(global: &Value, unnamed: UnnamedAddr) {
|
||||
unsafe {
|
||||
LLVMSetUnnamedAddress(global, unnamed);
|
||||
}
|
||||
pub(crate) fn set_unnamed_address(global: &Value, unnamed: UnnamedAddr) {
|
||||
LLVMSetUnnamedAddress(global, unnamed);
|
||||
}
|
||||
|
||||
pub(crate) fn set_thread_local_mode(global: &Value, mode: ThreadLocalMode) {
|
||||
@@ -260,9 +258,7 @@ pub(crate) fn set_initializer(llglobal: &Value, constant_val: &Value) {
|
||||
}
|
||||
|
||||
pub(crate) fn set_global_constant(llglobal: &Value, is_constant: bool) {
|
||||
unsafe {
|
||||
LLVMSetGlobalConstant(llglobal, if is_constant { ffi::True } else { ffi::False });
|
||||
}
|
||||
LLVMSetGlobalConstant(llglobal, if is_constant { ffi::True } else { ffi::False });
|
||||
}
|
||||
|
||||
pub(crate) fn get_linkage(llglobal: &Value) -> Linkage {
|
||||
|
||||
Reference in New Issue
Block a user