forked from OSchip/llvm-project
[llvm-c] Implement LLVMPrintValueToString
Original patch by Chris Wailes llvm-svn: 194135
This commit is contained in:
parent
08b0418828
commit
cd93b370d5
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue