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><div><br></div><div>-Sam</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 class="HOEnZb"><font color="#888888"><div><br></div><div>-Sam</div></font></span><div class="HOEnZb">
<div class="h5"><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>