[cfe-dev] using ASTWriter

Douglas Gregor dgregor at apple.com
Mon Sep 12 07:59:48 PDT 2011


On Sep 12, 2011, at 5:59 AM, Mark Brown wrote:

> 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



More information about the cfe-dev mailing list