aboutsummaryrefslogtreecommitdiffstats
path: root/lib/IR/Core.cpp
diff options
context:
space:
mode:
authorAnders Waldenborg <anders@0x63.nu>2013-10-16 18:00:54 +0000
committerAnders Waldenborg <anders@0x63.nu>2013-10-16 18:00:54 +0000
commit2906b519d1f47f1b269ed1be9c70f752b3dca928 (patch)
treebda283465c17ed6f3941e8a54c1b29a7b25f17c9 /lib/IR/Core.cpp
parentfc1604ec7274e9b724ff9b2512c288a691167427 (diff)
downloadexternal_llvm-2906b519d1f47f1b269ed1be9c70f752b3dca928.zip
external_llvm-2906b519d1f47f1b269ed1be9c70f752b3dca928.tar.gz
external_llvm-2906b519d1f47f1b269ed1be9c70f752b3dca928.tar.bz2
[llvm-c] Add LLVMPrintModuleToString.
Like LLVMDumpModule but returns the string (that needs to be freed with LLVMDisposeMessage) instead of printing it to stderr. Differential Revision: http://llvm-reviews.chandlerc.com/D1941 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192821 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR/Core.cpp')
-rw-r--r--lib/IR/Core.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp
index 95c516a..cf1c1df 100644
--- a/lib/IR/Core.cpp
+++ b/lib/IR/Core.cpp
@@ -147,6 +147,16 @@ LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename,
return false;
}
+char *LLVMPrintModuleToString(LLVMModuleRef M) {
+ std::string buf;
+ raw_string_ostream os(buf);
+
+ unwrap(M)->print(os, NULL);
+ os.flush();
+
+ return strdup(buf.c_str());
+}
+
/*--.. Operations on inline assembler ......................................--*/
void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm) {
unwrap(M)->setModuleInlineAsm(StringRef(Asm));