I tend to agree that this should use the Tooling/Refactoring stuff.<div><br></div><div>However, I'm curious about the best way to structure the location of migration candidates: AST matchers vs. visitor.</div><div><br>
</div><div>I can almost see the visitor pattern working really well here as each different construct can have a pile of migration logic dropped in.... But if there is a need to connect dots between more distant constructs, that wouldn't work so well.... Not at all sure what would be best here.</div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jun 29, 2012 at 1:37 AM, 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 class="gmail_quote"><div class="im">On Fri, Jun 29, 2012 at 4:06 AM, Sam Panzer <span dir="ltr"><<a href="mailto:panzer@google.com" target="_blank">panzer@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

In case anyone wanted to take a look, the attached patch includes the tool I've been working on. I create a new binary, c++migrate, which attempts to convert for loops in the source files given to it. Most of my focus has been on the FrontedAction, so I skirted all of the issues mentioned above by keeping the frontend interaction minimal (i.e. I just call Tooling::ClangTool::run), and the changes are just reported on standard output, if there are any to be made.<div>


<br></div><div>The tool can currently convert for loops that range over (1) statically allocated arrays, and (2) Clang-style iterator-based loops (with begin and end iterators defined). All loop variables need to be declared within the loop's initialization step in order for it to be converted, though this requirement can potentially be eliminated. I'm working on converting iterator-based loops that call someContainer.end() on each iteration, since they're probably the common case in many codebases.</div>


<div><br></div><div>Just for fun, I ran the tool over the 41 .cpp files in lib/Sema, and my tool found 71 convertible loops in 17 files. There is plenty more work to go, because it clearly missed some easy ones.</div><div>


<br></div><div>Any input or feedback is welcome!</div></blockquote><div><br></div></div><div>High-level observations:</div><div>1. the handling of the rewrites; any reason not to use the Tooling/Refactoring stuff? Currently in the patch it looks to me like the files are not rewritten, but dumped to stdout</div>

<div>2. is the reason not to use the matchers here that they're not landed in mainline yet?</div><div><br></div><div>Cheers,</div><div>/Manuel</div><div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<span><font color="#888888"><div><br></div><div>-Sam</div></font></span><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 28, 2012 at 10:50 AM, Sam Panzer <span dir="ltr"><<a href="mailto:panzer@google.com" target="_blank">panzer@google.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm that intern :)<span><font color="#888888"><div><br></div><div>-Sam</div></font></span><div>
<div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jun 27, 2012 at 9:48 PM, John Wiegley <span dir="ltr"><<a href="mailto:johnw@boostpro.com" target="_blank">johnw@boostpro.com</a>></span> wrote:<br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>>>>>> Sam Panzer <<a href="mailto:panzer@google.com" target="_blank">panzer@google.com</a>> writes:<br>




<br>
> In particular, I am working on a tool to convert existing C++ for loops to<br>
> take advantage of the new C++11 range-based syntax. I can imagine similar<br>
> tools to replace const with constexpr, macro hacks with static_assert, and<br>
> potentially other common refactorings.<br>
<br>
> Thoughts? Suggestions?<br>
<br>
</div>You really must watch this presentation, if you haven't already:<br>
<br>
    <a href="http://www.youtube.com/watch?v=yuIOGfcOH0k" target="_blank">http://www.youtube.com/watch?v=yuIOGfcOH0k</a><br>
<span><font color="#888888"><br>
--<br>
John Wiegley<br>
BoostPro Computing<br>
<a href="http://www.boostpro.com" target="_blank">http://www.boostpro.com</a><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></div></blockquote></div><br></div>
</div></div><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>
<br></blockquote></div></div></div><br>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">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>
<br></blockquote></div><br></div>