Hi,<div><br></div><div>I tried printing the ast for a simple Hello world "C" program using <b>clang-cc -ast-print hello.c</b>.</div><div><br></div><div>the output that I get is </div><div><br></div><div><div>typedef signed char __int8_t;</div>

<div>typedef unsigned char __uint8_t;</div><div>typedef short __int16_t;</div><div>typedef unsigned short __uint16_t;</div><div>typedef int __int32_t;</div><div>typedef unsigned int __uint32_t;</div><div>typedef long long __int64_t;</div>

<div>typedef unsigned long long __uint64_t;</div><div>typedef long __darwin_intptr_t;</div><div>typedef unsigned int __darwin_natural_t;</div><div>.</div><div>.</div><div>.</div><div>.</div><div>int main(int argc, char **argv) (CompoundStmt 0x1806170 <hello.c:3:1, line:10:1></div>
<div>  (DeclStmt 0x180f350 <line:4:3, col:12></div><div>    0x180e6a0 "int x"</div><div>    0x180f2f0 "int y"</div><div>    0x180f320 "int z"</div><div>.</div><div>.</div><div>.</div><div>
<br></div>
<div><br></div><div>If I want get/print the AST starting from <b>int main(int argc, char **argv) (CompoundStmt 0x1806170 <hello.c:3:1, line:10:1></b></div><div><b>  (DeclStmt 0x180f350 <line:4:3, col:12></b>, </div>
<div><br></div><div>How should I proceed ? </div><div><br></div>
<div>Also, I came across constant folding in the Clangs Internals Manual at <a href="http://clang.llvm.org/docs/InternalsManual.html#Constants">http://clang.llvm.org/docs/InternalsManual.html#Constants</a></div><div>Since I just started looking at Clang's code, I am not sure, if that really happens or not. But I need that the AST that I get be as close to the original source as possible.</div>
<div><br></div><div>Thanks for the help.</div><div><br></div><div>PS:-I wasn't aware the cfe-dev list existed , sorry:)</div><div><br></div><div>-Pushkar</div></div><div><br></div><div><br><br><div class="gmail_quote">
On Thu, Nov 5, 2009 at 3:22 AM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Pushkar Ratnalikar wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello,<br>
</blockquote>
<br>
This is more appropriate for cfe-dev, not llvmdev.  I'm forward this there;  please follow-up only to that list.<div><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I am trying to use Clang to generate AST for C code in a different format. This format is specific to the term rewriting system that we use for source-to-source transformations.<br>
<br>
Studying the ast generated by Clang using the "-ast-print" option to the clang-cc, I see that the pre-processor expands the code(expected). Is there a way to get around and not print all the information all the information and also keep the AST as close to the source as possible( avoiding constant folding).<br>


</blockquote>
<br></div>
Could you clarify what you mean by not printing all the information?<br>
<br>
We have several different textual AST dumping mechanisms in various states of decay, but I didn't realize any of them did constant folding.<br><font color="#888888">
<br>
John.<br>
</font></blockquote></div><br></div>