[llvm-c] Implement LLVMPrintValueToString

Original patch by Chris Wailes

llvm-svn: 194135
This commit is contained in:
Peter Zotov 2013-11-06 09:21:01 +00:00
parent 08b0418828
commit cd93b370d5
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));
}