[LLVMdev] Reading IR from a std::ostream

Paul J. Lucas paul at lucasmail.org
Sun Oct 21 19:30:49 PDT 2012

Previously I had asked how to write then read back IR to/from a file.  The write code looked like:

    LLVMContext ctx;
    SMDiagnostic diag;
    Module *m = ParseIRFile( "my_file", diag, ctx );

However, the code I'm trying to retrofit LLVM IR into passes me just a std::ostream&.  How can I read IR from a std::ostream?

I figured out how to use raw_os_ostream to adapt a std::ostream to a raw_ostream for writing a module, but there's no obvious way to adapt the code for reading, e.g., no MemoryBuffer that adapts a std::ostream (unless I missed it).

- Paul

More information about the llvm-dev mailing list