<div dir="ltr"><div class="gmail_default" style>On Mon, Jan 7, 2013 at 10:35 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br></div><div class="gmail_extra">
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Mon, Jan 7, 2013 at 1:29 PM, Pedro Delgado Perez<br>
<<a href="mailto:pedro.delgadoperez@mail.uca.es">pedro.delgadoperez@mail.uca.es</a>> wrote:<br>
> Thank you very much David.<br>
><br>
> Which interface would you recommend me to use for my purpose? I don't<br>
> understand really well what are the difference among them (LibClang,<br>
> Plugins, LibTooling or Clang Tools) and i would need to know the best option<br>
> for me. What I want is to create a tool reusing Clang only to analyze C++<br>
> programs. If you need more information to give me an answer, please tell me<br>
> what you would need to know.<br>
<br>
</div>If you're trying to do AST-matched source code transformations what<br>
you probably want is to use libTooling (to write a "Clang Tool") along<br>
with the AST matchers.<br>
<br>
<br>
[The one thing still pending that blocks truly streamlined refactoring<br>
tools using this infrastructure is the ability to automatically format<br>
the modified code so it's still legible (eg: re-wrapping lines when<br>
changing an identifier makes it shorter/longer), there's currently<br>
work underway (in the form of "clang-format") to support this. Once<br>
this functionality is combined with tooling and AST matchers we should<br>
have the ability to write fairly ad-hoc C++ refactoring tools that<br>
Just Work]<br>
<br>
[+Manuel to this thread in case he has anything to add]<br></blockquote><div><br></div><div style>Yep - you can already run clang-format over the diffs afterwards (daniel has a script that he plans to land soon).</div><div style>
<br></div><div style>Cheers,</div><div style>/Manuel</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="HOEnZb"><font color="#888888">
- David<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
><br>
> Thanks,<br>
><br>
> Pedro D.<br>
><br>
> El dia 07 ene 2013 17:29, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> escribió:<br>
><br>
> On Mon, Jan 7, 2013 at 2:44 AM, Pedro Delgado Perez<br>
> <<a href="mailto:pedro.delgadoperez@mail.uca.es">pedro.delgadoperez@mail.uca.es</a>> wrote:<br>
><br>
> Hello,<br>
> I've just known Clang looking for a soution to the task i need to perform.<br>
> Well, what I need is to parser a C++ program in order to get some<br>
> information about the code and, after that, to change the code regarding<br>
> that information collected.For instance, I would need to know if a certain<br>
> program contains some arithmetic operators., obtaining a record with the<br>
> line where the operator is located and which operator is. I've been reading<br>
> about Clang and now I know you can go through the AST, but i'm not totally<br>
> sure if it's what I'm looking for because apart from the example I've<br>
> commented above, I would need a lot of kinds of information:- What are the<br>
> global and the local variables.- If there is an overriden member when a<br>
> class inherits from another.- If a method of a class is overloaded.-...I<br>
> need that information because I have to change the original program once I<br>
> have the record with the information. For instance, if in the code there is<br>
> a reference to an overriden member, I have to turn that reference into the<br>
> hidden member.<br>
><br>
><br>
><br>
> The other question I have is: is it worth the effort and the time to learn<br>
> how to use clang? I need an opinion to know how easy or tough is to learn<br>
> how to use it.<br>
><br>
> I hope you could lend me a hand. Thanks in advance.<br>
><br>
> It depends a little on what alternatives you're considering. Clang<br>
> isn't necessarily going to be easy to get started with, especially<br>
> making source modifications, avoiding conflicts, etc, but it's<br>
> probably the easiest thing available to do this job well.<br>
><br>
> The tooling infrastructure ( <a href="http://clang.llvm.org/docs/Tooling.html" target="_blank">http://clang.llvm.org/docs/Tooling.html</a> )<br>
> and AST Matchers ( <a href="http://clang.llvm.org/docs/LibASTMatchers.html" target="_blank">http://clang.llvm.org/docs/LibASTMatchers.html</a> )<br>
> are designed to make this sort of task as easy & painless as possible.<br>
><br>
> - David<br>
</div></div></blockquote></div><br></div></div>