about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2013-10-11 19:56:11 -0400
committerDaniel Micay <danielmicay@gmail.com>2013-10-11 20:26:08 -0400
commit7bad4167654ef846155bae7165fd0ffcc24fcbbe (patch)
treec5acad50a7ff91138fddd98bf1d7c71a90ce63ee /src/rustllvm/RustWrapper.cpp
parent80878ff369cabc63967a6ebfd69f3e5fa692ceff (diff)
downloadrust-7bad4167654ef846155bae7165fd0ffcc24fcbbe.tar.gz
rust-7bad4167654ef846155bae7165fd0ffcc24fcbbe.zip
have LLVM print type strings for us
Example:

    void ({ i64, %tydesc*, i8*, i8*, i8 }*, i64*, %"struct.std::fmt::Formatter[#1]"*)*

Before, we would print 20 levels deep due to recursion in the type
definition.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
-rw-r--r--src/rustllvm/RustWrapper.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp
index 31a02dceb1c..f8d56f4e892 100644
--- a/src/rustllvm/RustWrapper.cpp
+++ b/src/rustllvm/RustWrapper.cpp
@@ -803,3 +803,10 @@ extern "C" void LLVMDICompositeTypeSetTypeArray(
 {
     unwrapDI<DICompositeType>(CompositeType).setTypeArray(unwrapDI<DIArray>(TypeArray));
 }
+
+extern "C" char *LLVMTypeToString(LLVMTypeRef Type) {
+    std::string s;
+    llvm::raw_string_ostream os(s);
+    unwrap<llvm::Type>(Type)->print(os);
+    return strdup(os.str().data());
+}