]> granicus.if.org Git - llvm/commitdiff
llvm-c: Add LLVMPrintTypeToString
authorAnders Waldenborg <anders@0x63.nu>
Tue, 22 Oct 2013 06:58:34 +0000 (06:58 +0000)
committerAnders Waldenborg <anders@0x63.nu>
Tue, 22 Oct 2013 06:58:34 +0000 (06:58 +0000)
Differential Revision: http://llvm-reviews.chandlerc.com/D1963

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193149 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm-c/Core.h
lib/IR/Core.cpp

index f9717cc5f55121f1997fb8a3452b566e4560f1f4..a48ea7e74571ecf52700c4acf1f6177f86ab2ade 100644 (file)
@@ -722,6 +722,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
  *
index 7d52386b061ad85f9a463149814d8cbca513f92c..16af7332d3cca466350140ca379374d5c061118b 100644 (file)
@@ -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)  {