<div dir="ltr">   Thanks a lot. I will report back any results. If you are interested, I am using clang to write a provenance collection tool. Basically, clang is used to rewrite a program such that it emits provenance information at runtime. The literal meaning of provenance is "origin". The resulting code after passing through my tool will report all function calls, their arguments and return calls. It will be able to generate a complete runtime control flow graph. This project is in collaboration with the Stanford Research Institute and I will be very happy if you might consider making it part of the clang extras (once it is done ). <div>
   Any guidance on compiler theory would be much appreciated. Both my supervising professors are experts in information theory and security so it's up to me to figure all the things related to compilers.</div><div><br>
</div><div>Regards,</div><div>Adil <br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 25, 2013 at 8:30 PM, Manuel Klimek <span dir="ltr"><<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="im">On Fri, Jan 25, 2013 at 4:26 PM, Mohammad Adil <span dir="ltr"><<a href="mailto:madil90@gmail.com" target="_blank">madil90@gmail.com</a>></span> wrote:<br>
</div><div class="gmail_extra"><div class="gmail_quote"><div class="im">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>Hi,</div>  I am interested in helping any way I can. I am a research assistant and always looking to help the community. Unfortunately, I am new to compiler theory. If you can give me a few guidelines on how to achieve that, I would be glad to help. Also, can you please name a few good resources on compiler theory (my university isn't focusing on compilers so not many people here to help). </div>

</blockquote><div><br></div></div><div>+dgregor, who would be the right person to guide you here (or delegate said guidance to the right person).</div><div class="im"><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<div dir="ltr"><div>
   Regarding clang, what exactly happens when clang encounters an error (I mean i want to pause the recursive visitor at the point when it encounters an error and not end the program). Also, is it possible to </div></div>

</blockquote><div><br></div></div><div>The RecursiveASTVisitor runs *after* clang finished parsing the program. Thus, I would think what you want to do is pretty much impossible.</div><div class="im"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<div dir="ltr"><div>parse the code in rewriter buffer without saving it (parse on the fly).</div></div></blockquote><div><br></div></div><div>Yes, that's definitely possible. You can look at the examples in the c++11 migration tool in the clang-extra-tools repository (<a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/cpp11-migrate/" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/cpp11-migrate/</a>)</div>
<div><div class="h5">
<div><br></div><div>Cheers,</div><div>/Manuel</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<div dir="ltr">
<div><br></div><div>Regards,</div><div>Adil</div></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 25, 2013 at 7:52 PM, Manuel Klimek <span dir="ltr"><<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>On Fri, Jan 25, 2013 at 3:43 PM, Mohammad Adil <span dir="ltr"><<a href="mailto:madil90@gmail.com" target="_blank">madil90@gmail.com</a>></span> wrote:<br>


</div><div class="gmail_extra"><div class="gmail_quote"><div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Let us say that I write some code which has some errors. Now I am reparsing it. Can I halt the parsing when I encounter an error so that I can remedy it? If so, what happens to the AST? I mean, does it break at that point or does it contain the rest of the code too with some kind of substitution for the error part?</div>



</blockquote><div><br></div></div><div>No, if you reparse it and it breaks, all you know is that what you wanted to do was incorrect... As I mentioned, whether this is a practical approach depends on what your fallback strategy is - for example, if you don't want to do anything in case of an error, simply not saving after getting an error in the reparsing would solve the problem.</div>



<div><br></div><div>That said, it would be really cool to have full access to the lookup after the semantic analysis - so if you're interested in tackling this, I'd expect that you'd make a lot of people very happy :D</div>



<div><br></div><div>Cheers,</div><div>/Manuel</div><div><div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<div dir="ltr"><div>
<div><br></div></div></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 25, 2013 at 7:31 PM, Manuel Klimek <span dir="ltr"><<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>></span> wrote:<br>




<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>On Fri, Jan 25, 2013 at 2:57 PM, Mohammad Adil <span dir="ltr"><<a href="mailto:madil90@gmail.com" target="_blank">madil90@gmail.com</a>></span> wrote:<br>




</div><div class="gmail_extra"><div class="gmail_quote"><div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">I need to insert some code in the file being parser. I need to make sure that the resulting file compiles fine. The code that I am inserting will mostly be " ostream << type_x ;". Now before I do that, I need to ensure that "type_x" has a stream operator defined. Is that possible any other way? I am very grateful for your help.</div>





</blockquote><div><br></div></div><div>What we do in the c++11 transition tools in clang-extra is:</div><div>- parse</div><div>- detect place to insert</div><div>- insert</div><div>- reparse, look for errors</div>
<div><br></div><div>Whether that's viable depends on how big the chance is that you're making an error, and what fallbacks you have.</div><div><div><div><br></div><div>Cheers,</div><div>/Manuel</div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>
<br></div><div>Regards,</div><div>Adil</div></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 25, 2013 at 6:34 PM, Manuel Klimek <span dir="ltr"><<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>></span> wrote:<br>






<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div>On Fri, Jan 25, 2013 at 1:13 PM, Mohammad Adil <span dir="ltr"><<a href="mailto:madil90@gmail.com" target="_blank">madil90@gmail.com</a>></span> wrote:<br>






</div><div class="gmail_extra"><div class="gmail_quote"><div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Thanks for the reply. Well, here's the detailed problem. Once all the syntax checking has been done, the next step before generating IR is to do semantic analysis and type checking. Let us say that I encounter a code like this:<div>








<br></div><div>string b;</div><div>vector<T> a;</div><div>cout<<b;</div><div>cout<<a;</div><div> </div><div>      How does clang figure out that the 3rd statement is valid because an operator for string exists, while the 4rth statement is not valid. More specifically, I want to know how clang searches through all the operators (or functions). I have to use this functionality. Does the clang api allow me to do this easily or will I have to replicate this functionality?</div>







</div></blockquote><div><br></div></div><div>As far as I know the clang API does not allow you to do that easily - you need the full semantic analysis state at that point during parsing, and as far as I'm aware this only exists implicitly in the Sema* classes. Overload resolution is one of those really complex and messy parts of C++ :)</div>







<div><br></div><div>If you let us know what actual problem you're trying to solve, there might be solutions to that which are simpler than using overload resolution :)</div><div><div><div><br></div><div>
Cheers,</div><div>/Manuel</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">

<div>Regards,</div><div>Adil</div><div><br></div><div><br>
</div><div>        </div></div><div class="gmail_extra"><div><div><br><br><div class="gmail_quote">On Fri, Jan 25, 2013 at 4:35 PM, Manuel Klimek <span dir="ltr"><<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>></span> wrote:<br>








<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">On Thu, Jan 24, 2013 at 12:49 PM, madil90 <span dir="ltr"><<a href="mailto:madil90@gmail.com" target="_blank">madil90@gmail.com</a>></span> wrote:<br>








<div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Hi,<br>
   I am looking to perform some semantic analysis in clang. More<br>
specifically, I want to know whether a function exists for a certain type.<br>
The function is global. e.g.<br>
<br>
String toString(A a);<br>
<br>
    I want to differentiate that this function exists for type A and not for<br>
type B. I have built an AST and am parsing it. How can I achieve this?<br>
(Whenever I encounter a type)<br></blockquote><div><br></div><div>I'd loop over all declarations of toString and see which type they take... Perhaps I'm misunderstanding your problem though :)</div><div>
<br></div><div>Cheers,</div><div>/Manuel</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


<br>
Regards,<br>
Adil<br>
<br>
<br><span><font color="#888888">
<br>
--<br>
View this message in context: <a href="http://clang-developers.42468.n3.nabble.com/Semantic-Analysis-in-Clang-tp4030012.html" target="_blank">http://clang-developers.42468.n3.nabble.com/Semantic-Analysis-in-Clang-tp4030012.html</a><br>










Sent from the Clang Developers mailing list archive at Nabble.com.<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</font></span></blockquote></div><br></div></div>
</blockquote></div><br><br clear="all"><div><br></div></div></div><span><font color="#888888">-- <br>Mohammad Adil<div>LUMS SSE</div>
</font></span></div>
</blockquote></div></div></div><br></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Mohammad Adil<div>LUMS SSE</div>
</div>
</div></div></blockquote></div></div></div><br></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Mohammad Adil<div>LUMS SSE</div>
</div>
</div></div></blockquote></div></div></div><br></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Mohammad Adil<div>LUMS SSE</div>
</div>
</div></div></blockquote></div></div></div><br></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Mohammad Adil<div>LUMS SSE</div>
</div></div></div>