[cfe-dev] using ASTWriter::WriteAST() in ASTConsumer

Mark Brown mbrowncu98 at gmail.com
Mon Sep 12 15:35:54 PDT 2011


I will try using it, but it makes me wonder what th point of ASTWriter is.
And why it even takes in a filename.

On Mon, Sep 12, 2011 at 6:18 PM, Argyrios Kyrtzidis <kyrtzidis at apple.com>wrote:

>
> On Sep 12, 2011, at 12:40 PM, Mark Brown wrote:
>
> > I wrote a plugin which in inherits both the ASTConsumer and
> RecursiveASTVisitor classes. Before the plugin is over I would like it to
> write out my modified AST.
> >
> > Currently this code does nothing. No errors, not output. As there are no
> return values or error checking function I'm not even sure how I'm supposed
> to debug it. Does anyone happen to see whats wrong?
> >
> > Thank you
> >
> > virtual void HandleTranslationUnit(ASTContext &ctx) {
> >                 TraverseDecl(ctx.getTranslationUnitDecl());
> >
> >                 std::vector<unsigned char> buf;
> >                 BitstreamWriter stream_writer(buf);
> >                 ASTWriter ast_writer(stream_writer);
> >                 ast_writer.WriteAST(ci->getSema(), NULL,
> string("test.ast"), StringRef("wtf"));
> > }
>
> It wrote the AST data into the vector buf, you want to write the vector
> into a file I assume ?
> Check out the ASTUnit::Save function.
>
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110912/58f3284b/attachment.html>


More information about the cfe-dev mailing list