<font color="#330099"><font><font face="georgia,serif"><br>Hey James,<br><br>Thanks for the command line option. But where is the function called? I mean in which main method of clang it is called? We know that every function must be called at least at one main method/function to be executed. Let me make it clear like this way:<br>

<br>int main ()//main method<br>{<br>S->Printpretty(context);<br>}</font></font></font><br><br><span style="color:rgb(102,51,255)">So, which main method is calling our printpretty() function? Hope now its clear for you.</span><br style="color:rgb(102,51,255)">

<br><div class="gmail_quote">On Mon, Dec 12, 2011 at 9:49 PM, James Molloy <span dir="ltr"><<a href="mailto:james.molloy@arm.com">james.molloy@arm.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">










<div link="blue" vlink="purple" lang="EN-GB">

<div>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Hi Eyasu,<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Ah, I understand your question better now. Clang has an option “-ast-print”
that does what you want. It is a cc1 option though, so you can’t access it
directly through the driver.<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">$ clang –cc1 –help<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Will show it, and to use it:<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">$ clang –Xclang –ast-print –S x.c –o –<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Int x;<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">The “-Xclang” forces the next argument to be passed directly to
the cc1 executable, which will recognise it.<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Hope this helps,<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">James<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>

<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm">

<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" lang="EN-US">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" lang="EN-US"> eyasu getahun [mailto:<a href="mailto:eya.get@gmail.com" target="_blank">eya.get@gmail.com</a>] <br>


<b>Sent:</b> 12 December 2011 13:45<br>
<b>To:</b> James Molloy<br>
<b>Cc:</b> <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<b>Subject:</b> Re: [cfe-dev] main functions of clang<u></u><u></u></span></p>

</div><div><div class="h5">

<p class="MsoNormal"><u></u> <u></u></p>

<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-family:"Georgia","serif";color:#330099"><br>
Hello James,<br>
<br>
Thanks a lot for your help and sorry for my late reply. Your information is
helpful, however what I want to know is the main method of clang that calls the
printpretty() function. As you mentioned, lets have S
->printpretty(context). We can see this at StmtPrinter.cpp  class as I
mentioned earlier. My question is which main method of clang this function is
called. As we know at run time there is at least on main method that calls
other functions. Assume we want to print the source code of AST. We will run
clang on command line. we will use a command(I don't know the command) that
calls the print pretty function. Hope you get my idea. So, which main method/function
of clang is calling this function? Thanks again.</span><u></u><u></u></p>

<div>

<p class="MsoNormal">On Mon, Dec 12, 2011 at 7:04 PM, James Molloy <<a href="mailto:James.Molloy@arm.com" target="_blank">James.Molloy@arm.com</a>> wrote:<u></u><u></u></p>

<div>

<div>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Hi,</span><u></u><u></u></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">If
you look at Stmt.h, you will find the main declarations for printPretty and
dumpPretty (line 305). They are member functions of the Stmt class, so assuming
you have a Stmt instance you can just call “S->dumpPretty(Context);”</span><u></u><u></u></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">It’s
difficult to give a general rule for everything in Clang – as you know it is
quite a complex source base. But hopefully this has helped?</span><u></u><u></u></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Cheers,</span><u></u><u></u></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">James
</span><u></u><u></u></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></p>

<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm">

<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" lang="EN-US">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"" lang="EN-US"> <a href="mailto:cfe-dev-bounces@cs.uiuc.edu" target="_blank">cfe-dev-bounces@cs.uiuc.edu</a>
[mailto:<a href="mailto:cfe-dev-bounces@cs.uiuc.edu" target="_blank">cfe-dev-bounces@cs.uiuc.edu</a>]
<b>On Behalf Of </b>eyasu getahun<br>
<b>Sent:</b> 12 December 2011 10:40<br>
<b>To:</b> <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<b>Subject:</b> [cfe-dev] main functions of clang</span><u></u><u></u></p>

</div>

<div>

<p class="MsoNormal"> <u></u><u></u></p>

<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-family:"Georgia","serif";color:#330099"> Hello All,<br>
<br>
Clang has a number of classes and functions inside its implementation. Most of
the time it makes me to be confused to identify the interconnection among
classes and functions. Because many functions may be called from different
header files. The main thing what i want to know is about main methods of
clang. I have seen 4 main functions in clang. But it is difficult for me to
identify in which main methods are other functions called. To make it clear let
me talk about one class(example StmtPrinter.cpp class). This class prints back
source code from AST.  Under this class their are two functions i.e
PrintPretty(..) and DumpPretty(..). Suppose I want to use printPretty(..) and
it is called at different functions.  Where is the main method of clang
that calls this function to print the source code? Can someone tell me how it
works. I tried to greped out on command line but failed to get the main method
that calls this function. Even I want to know the command to use this function.
<br>
<br>
Sorry, it might be silly question, but I failed to get it out. Thanks in
advance for your help!.</span><u></u><u></u></p>

</div>

</div>

<p class="MsoNormal"><br>
<span style="font-family:"Arial","sans-serif";color:black">-- IMPORTANT NOTICE:
The contents of this email and any attachments are confidential and may also be
privileged. If you are not the intended recipient, please notify the sender
immediately and do not disclose the contents to any other person, use it for
any purpose, or store or copy the information in any medium. Thank you.</span><u></u><u></u></p>

</div>

</div>

<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
<br clear="all">
<br>
-- <br>
<b>With Best Regards,<br>
<br>
===========================================<br>
Eyasu Getahun</b><br>
<br>
1 Fusionopolis way, #08-10 Connexis North Tower<br>
Singapore 138632, Singapore<br>
Mobile: <a href="tel:%2B393279239907" value="+393279239907" target="_blank">+393279239907</a><br>
<b>===========================================</b><u></u><u></u></p>

</div></div></div>

</div>

</blockquote></div><br><br clear="all"><br>-- <br><b>With Best Regards,<br><br>===========================================<br>Eyasu Getahun</b><br><br>1 Fusionopolis way, #08-10 Connexis North Tower<br>Singapore 138632, Singapore<br>

Mobile: +393279239907<br><b>===========================================<br></b><br>