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?
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?
I ran into some problems using @eush77's answer. Here is my fix.
std::string str;
llvm::raw_string_ostream ss(str);
ss << I;
errs() << ss.str() << "\n";