[cfe-dev] Chaining multiple AST consumers

moataz ragab mtzrgb at gmail.com
Thu Apr 8 19:58:55 PDT 2010


Hi,

I would like to pre-process the AST before I do actual analysis on it. For
example I would like to normalize loops first.  I have three solutions in
mind

1) I know that I can write the AST to a file after processing and read it
again. But that will make the process complicated and slower
2) I can add the code as separate functions in the ASTConsumer that I will
use but that will limit the reusability of the loop normalization.
3) I can make loop normalization code in a StmtVisitor and call it when I
reach function body. but that will make a separate traversal of the AST
tree.
4) Make a separate ASTConsumer. but in this case I need to enable ParseAST
to handle multiple consumers (maybe by passing a vector of the ASTConsumers)
and having ParseAST call them one after the other but that will require
modifying the Clang builtin function ParseAST plus I am not sure if there
might be other issues involved (Do I have to worry about the context? I am
not changing the types)

Is option 4 a viable option? Do you have another option?

Thanks,
Moataz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100409/d832b94b/attachment.html>


More information about the cfe-dev mailing list