using ASTWriter

I’m finding this class to be a bit confusing.

The constructor requires llvm::BitstreamWriter &Stream, which makes sense, that is the output I want. But the constructor for the BitstreamWriter requires std::vector< unsigned char > &O. What is this? I was expecting only a filename or some kind of file object. I also cant seem to dig up a example of using a BitstreamWriter to see its use. Is there more to it?

After the ASTWriter is created, would I only have to call its WriteAST() method to have a complete IR dump of my modified(in a plugin) AST?

Thank you

I'm finding this class to be a bit confusing.

The constructor requires llvm::BitstreamWriter &Stream, which makes sense, that is the output I want. But the constructor for the BitstreamWriter requires std::vector< unsigned char > &O. What is this? I was expecting only a filename or some kind of file object. I also cant seem to dig up a example of using a BitstreamWriter to see its use. Is there more to it?

that vector<unsigned char> is the buffer into which the bitstream will be written. You can dump it to a file yourself.

After the ASTWriter is created, would I only have to call its WriteAST() method to have a complete IR dump of my modified(in a plugin) AST?

Basically, yes. There are a handful of uses of ASTWriter in the Clang code base; I suggest looking at one if you get stuck. They're fairly straightforward.

  - Doug