]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_codegen_llvm/lib.rs
Removed code duplication for CommonWriteMethods
[rust.git] / src / librustc_codegen_llvm / lib.rs
index 2ef90c03c67ec777a25ff9782c2743d16141b569..e228dc044f17700932801aa23adddcc8f3574474 100644 (file)
@@ -76,7 +76,6 @@
 use std::any::Any;
 use std::sync::mpsc;
 use std::marker::PhantomData;
-use libc::{c_uint, c_char};
 use rustc_data_structures::sync::Lrc;
 
 use rustc::dep_graph::DepGraph;
@@ -361,20 +360,11 @@ fn llmod(&self) -> &llvm::Module {
 
 impl CommonWriteMethods for ModuleLlvm<'ll> {
     fn val_ty(&self, v: &'ll Value) -> &'ll Type {
-        unsafe {
-            llvm::LLVMTypeOf(v)
-        }
+        common::val_ty(v)
     }
 
     fn c_bytes_in_context(&self, llcx: &'ll llvm::Context, bytes: &[u8]) -> &'ll Value {
-        unsafe {
-            let ptr = bytes.as_ptr() as *const c_char;
-            return llvm::LLVMConstStringInContext(
-                llcx,
-                ptr,
-                bytes.len() as c_uint,
-                llvm::True);
-        }
+        common::c_bytes_in_context(llcx, bytes)
     }
 
     fn c_struct_in_context(
@@ -383,11 +373,7 @@ fn c_struct_in_context(
         elts: &[&'a Value],
         packed: bool,
     ) -> &'a Value {
-        unsafe {
-            llvm::LLVMConstStructInContext(llcx,
-                                           elts.as_ptr(), elts.len() as c_uint,
-                                           packed as llvm::Bool)
-        }
+        common::c_struct_in_context(llcx, elts, packed)
     }
 }