If I
is of type llvm::Instruction
, we can print out the same in human-readable form (textual representation) by errs() << I;
I want the assign the exact same representation to a std::string
to C type string. How can I do that?
Well, LLVM provides a string stream as well:
#include <llvm/Support/raw_ostream.h>
Use it like this:
std::string str;
llvm::raw_string_ostream(str) << I;
// use str