[llvm-c] Implement LLVMPrintValueToString

Original patch by Chris Wailes

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194135 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Peter Zotov 2013-11-06 09:21:01 +00:00
parent 7851bc1871
commit 14bbb1d9b0
2 changed files with 18 additions and 0 deletions

View File

@ -1211,6 +1211,14 @@ void LLVMSetValueName(LLVMValueRef Val, const char *Name);
*/
void LLVMDumpValue(LLVMValueRef Val);
/**
* Return a string representation of the value. Use
* LLVMDisposeMessage to free the string.
*
* @see llvm::Value::print()
*/
char *LLVMPrintValueToString(LLVMValueRef Val);
/**
* Replace all uses of a value with another one.
*

View File

@ -474,6 +474,16 @@ void LLVMDumpValue(LLVMValueRef Val) {
unwrap(Val)->dump();
}
char* LLVMPrintValueToString(LLVMValueRef Val) {
std::string buf;
raw_string_ostream os(buf);
unwrap(Val)->print(os);
os.flush();
return strdup(buf.c_str());
}
void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal) {
unwrap(OldVal)->replaceAllUsesWith(unwrap(NewVal));
}