<html><head><base href="x-msg://622/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Feb 17, 2012, at 11:38 AM, Aditya Kumar wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div class="hmmessage" style="font-size: 10pt; font-family: Tahoma; "><div dir="ltr">For my project(related to source code analysis of C++ program) I  need to traverse the clang AST to figure out all the places<div>where the preprocessor macros are called in the program.<div><div>I am fairly new to clang to be honest.</div></div></div></div></div></span></blockquote><div><br></div><div>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.</div><div><br></div><div>Jason</div><div><br></div><br><blockquote type="cite"><span class="Apple-style-span" style="font-family: Tahoma; font-size: 13px; ">1. What i want to know is whether the preprocessor gets called before the parser or </span><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div class="hmmessage" style="font-size: 10pt; font-family: Tahoma; "><div dir="ltr"><div><div><div>it gets called from the parser as each token is seen by it.</div><div>2. How can I obtain the AST of a C++ program which has been generated without any preprocessing.</div><div>Even if there is some syntax-error in doing so, it is okay.</div><div><br></div></div></div><div>Thanks.</div></div>_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a></div></span></blockquote></div><br></body></html>