summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Waldenborg <anders@0x63.nu>2013-10-22 06:58:34 +0000
committerAnders Waldenborg <anders@0x63.nu>2013-10-22 06:58:34 +0000
commit47b3bd3fbb131b47268af300a65af52c159052dc (patch)
tree7784adf599940be8612e2553d23aa78a600cbd7a
parent3461bedbfd1531fd40c252b77aaf3c04900b50ee (diff)
downloadbcm5719-llvm-47b3bd3fbb131b47268af300a65af52c159052dc.tar.gz
bcm5719-llvm-47b3bd3fbb131b47268af300a65af52c159052dc.zip
llvm-c: Add LLVMPrintTypeToString
Differential Revision: http://llvm-reviews.chandlerc.com/D1963 llvm-svn: 193149
-rw-r--r--llvm/include/llvm-c/Core.h8
-rw-r--r--llvm/lib/IR/Core.cpp10
2 files changed, 18 insertions, 0 deletions
diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h
index f9717cc5f55..a48ea7e7457 100644
--- a/llvm/include/llvm-c/Core.h
+++ b/llvm/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/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index 7d52386b061..16af7332d3c 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/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) {
OpenPOWER on IntegriCloud