diff options
-rw-r--r-- | include/llvm-c/Core.h | 8 | ||||
-rw-r--r-- | lib/IR/Core.cpp | 10 |
2 files changed, 18 insertions, 0 deletions
diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index f9717cc..a48ea7e 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -723,6 +723,14 @@ LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty); void LLVMDumpType(LLVMTypeRef Val); /** + * Return a string representation of the type. Use + * LLVMDisposeMessage to free the string. + * + * @see llvm::Type::print() + */ +char *LLVMPrintTypeToString(LLVMTypeRef Val); + +/** * @defgroup LLVMCCoreTypeInt Integer Types * * Functions in this section operate on integer types. diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp index 7d52386..16af733 100644 --- a/lib/IR/Core.cpp +++ b/lib/IR/Core.cpp @@ -224,6 +224,16 @@ void LLVMDumpType(LLVMTypeRef Ty) { return unwrap(Ty)->dump(); } +char *LLVMPrintTypeToString(LLVMTypeRef Ty) { + std::string buf; + raw_string_ostream os(buf); + + unwrap(Ty)->print(os); + os.flush(); + + return strdup(buf.c_str()); +} + /*--.. Operations on integer types .........................................--*/ LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C) { |