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

Mark Brown mbrowncu98 at gmail.com
Mon Sep 12 12:40:49 PDT 2011


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"));
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110912/1ce4b66c/attachment.html>


More information about the cfe-dev mailing list