[cfe-dev] Preprocessor/Parser interaction

Jason Haslam jason.haslam at gmail.com
Fri Feb 17 12:45:26 PST 2012


On Feb 17, 2012, at 11:38 AM, Aditya Kumar wrote:

> For my project(related to source code analysis of C++ program) I  need to traverse the clang AST to figure out all the places
> where the preprocessor macros are called in the program.
> I am fairly new to clang to be honest.

If you only need information about where macros are used then there's no need to traverse the AST at all. The PPCallbacks mechanism allows clients to observe the interesting aspects of preprocessing. In particular the MacroExpands callback is invoked every time a macro is used.

Jason


> 1. What i want to know is whether the preprocessor gets called before the parser or 
> it gets called from the parser as each token is seen by it.
> 2. How can I obtain the AST of a C++ program which has been generated without any preprocessing.
> Even if there is some syntax-error in doing so, it is okay.
> 
> Thanks.
> _______________________________________________
> 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/20120217/bbb5ef32/attachment.html>


More information about the cfe-dev mailing list