Skip to content

Commit

Permalink
trans: Add Type::to_string method to improve options for debug output.
Browse files Browse the repository at this point in the history
  • Loading branch information
pnkfelix committed Jul 28, 2015
1 parent 661a5ad commit 39ec9f8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/librustc_trans/trans/type_.rs
Expand Up @@ -50,6 +50,12 @@ impl Type {
self.rf
}

pub fn to_string(self: Type) -> String {
llvm::build_string(|s| unsafe {
llvm::LLVMWriteTypeToString(self.to_ref(), s);
}).expect("non-UTF8 type description from LLVM")
}

pub fn void(ccx: &CrateContext) -> Type {
ty!(llvm::LLVMVoidTypeInContext(ccx.llcx()))
}
Expand Down Expand Up @@ -315,9 +321,7 @@ impl TypeNames {
}

pub fn type_to_string(&self, ty: Type) -> String {
llvm::build_string(|s| unsafe {
llvm::LLVMWriteTypeToString(ty.to_ref(), s);
}).expect("non-UTF8 type description from LLVM")
ty.to_string()
}

pub fn types_to_str(&self, tys: &[Type]) -> String {
Expand Down

0 comments on commit 39ec9f8

Please sign in to comment.