[cfe-dev] A howto or template for adding a transformation pass

Hiren Patel hirenvt at gmail.com
Fri Aug 8 06:38:56 PDT 2008


I'd like to find the best method of adding a transformation pass that uses
the AST and the CFG. Is there a template or a how-to on this?

My goal in summary is to:

1. Determine declarations of certain new statements (beginD and endD) in the
C source (without changing the front-end; they are simple macros).
2. Replace the statements with certain macros with additional labels.
4. Output the changed C file.

I've successfully tried the following:

- Added an Analysis consumer, but I noticed that this Analysis consumer
method is invoked twice; once for each function in the C source. I'd like to
have access to the full Analysis and then walk it using walker methods.
- Added an ASTConsumer, but again, this is invoked twice. Once per function.

Your suggestions would be much appreciated.

~ Hiren
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080808/83e73423/attachment.html>

More information about the cfe-dev mailing list