<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 21 March 2017 at 21:44, Johannes Altmanninger via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">So I have been playing around with this some more.<br>
<span class=""><br>
> Yes. But we developed software as libraries usually. Practically I<br>
> expect the main part of the work to write some piece of API that<br>
> generate an “in-memory” representation of the diff.<br>
<br>
</span>Yes, of course, I think the representation will be just a set of<br>
changes, where a change is a insert/update/removal of a node.<br>
<span class=""><br>
> In the future I hope it’d enable other graphical diff client to<br>
> plug-in, or git-merge resolution tools as well.<br>
</span>Yes, merge tools would be a nice application for this, as Hal also<br>
pointed out. Of course it is easy to make the output machine readable or<br>
just use the API in the first place.<br>
<br>
Unfortunately it is not possible to (de-)serialize the AST from/to XML<br>
(or some other structured data format). If it was, one could use<br>
existing structural diff tools to make prototypes or help test the final<br>
version.<br>
<br>
I have another question as I have never written a clang tool before: One<br>
could use LibClang or LibTooling, the former seems easier and probably<br>
good enough (?)<br></blockquote><div><br></div><div>Hi Johannes,</div><div>I think a tool like this should use LibTooling directly since libclang does not expose all of the information that's present in the AST.</div><div>Alex</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Furthermore, should I work on a small patch / fix an easy bug to show<br>
that I am comfortable with the development process? I am a bit lost with<br>
the bug tracker, so if you can suggest things to work I will try that.<br>
Other than that I can work on a prototype for the tool but that takes<br>
some time.  I found one small typo in clang, I guess I could submit<br>
that..<br>
<br>
Johannes<br>
<br>
<br>
diff --git a/include/clang/AST/<wbr>RecursiveASTVisitor.h b/include/clang/AST/<wbr>RecursiveASTVisitor.h<br>
index 1b5850a05b..c31e4b0bb4 100644<br>
--- a/include/clang/AST/<wbr>RecursiveASTVisitor.h<br>
+++ b/include/clang/AST/<wbr>RecursiveASTVisitor.h<br>
@@ -83,7 +83,7 @@ namespace clang {<br>
       return false;                                                            \<br>
   } while (false)<br>
<br>
-/// \brief A class that does preordor or postorder<br>
+/// \brief A class that does preorder or postorder<br>
 /// depth-first traversal on the entire Clang AST and visits each node.<br>
 ///<br>
 /// This class performs three distinct tasks:<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
Mehdi Amini <<a href="mailto:mehdi.amini@apple.com">mehdi.amini@apple.com</a>> writes:<br>
<br>
> (+CC: Greg Clayton who gave me this idea in the first place)<br>
><br>
>> On Mar 20, 2017, at 3:20 PM, Johannes Altmanninger via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
>><br>
>> Hello,<br>
>><br>
>> I am currently studying Computer Science at TU Eindhoven. I am doing a<br>
>> course that involves programming assignments on parts of LLVM such as<br>
>> lowering, scheduling and optimization. For this year's Google Summer of<br>
>> Code I plan to submit a proposal to implement a clang-based diff tool<br>
>> [1].<br>
><br>
> Great! I look forward to see this :)<br>
><br>
>><br>
>> I think it really pays off to have decent developer tools available, as<br>
>> they can save tons of time. Clang tooling has obviously been very<br>
>> successful.  I think it would be a good idea to develop a diff tool that<br>
>> considers the structure of the code, as opposed to just the lines. Plain<br>
>> old diff only thinks in terms of "additions" and "deletions", although<br>
>> it would be more natural to also consider "updates" and "moves".<br>
>><br>
>> So a structural diff would work solely on the AST, hence formatting<br>
>> changes are ignored. It would allow to highlight the exact location of a<br>
>> change, and not a whole line. Furthermore, it would allow to compare<br>
>> pieces of code with the same structure (think subclasses).<br>
>><br>
>> Besides some papers with clever AST-matching algorithms, a quick web<br>
>> search yielded [2], which is a proof-of-concept implementation of a<br>
>> structural comparison algorithm.  I think it demonstrates rather nicely<br>
>> what could be done: movement of chunks of code can be easily traced.<br>
>><br>
>> Anyway, one could make all kinds of nice visualizations using a AST diff<br>
>> tool, however, I think the initial focus should probably be on creating<br>
>> one with a similar output to traditional diff, with the difference that<br>
>> updates and moves are displayed in a easily readable way, which already<br>
>> could improve developer productivity and happiness.<br>
>><br>
>> As of now I have one question: The output of the tool is meant just for<br>
>> humans to read (and not for actual patching), right?<br>
><br>
> Yes. But we developed software as libraries usually. Practically I expect the main part of the work to write some piece of API that generate an “in-memory” representation of the diff.<br>
><br>
> A tool that is generating a textual-human readable output is likely the first client of this API and is likely critical to be able to functionally test it in the early development. In the future I hope it’d enable other graphical diff client to plug-in, or git-merge resolution tools as well.<br>
><br>
> Best,<br>
><br>
> —<br>
> Mehdi<br>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</div></div></blockquote></div><br></div></div>