[cfe-dev] [PATCH] For loop migration tool (round 1)

Sam Panzer panzer at google.com
Fri Aug 3 16:14:00 PDT 2012


Here are three patches which constitute most of the work needed for the
for-loop migration tool. The first contains the contents of the tutorial
from earlier this week, with extra comments and rebased into
clang/tools/extra/. The second patch fixes most of the correctness
assumptions that the naive tool makes (e.g. conflicting edits, name
conflicts), and the third adds some command-line flags along with a trick
for eliding a variable declared as a reference to the array access.

Together, they provide a nearly complete converter for array-based loops -
the three optional features I didn't rebase into the patches involve using
an explicit type rather than auto, adding const when possible, and making
the loop variable a non-reference type for non-aggregate types if possible.

There is one potentially problematic assumption that I haven't fixed yet:
the array expression is assumed not to change, as this becomes difficult to
verify when the code iterates over a compound expression such as
graph.nodes->getInputs(). In most cases, the loop will probably be
convertible if it passes all other checks, so I intend to offer a flag that
tells the loop converter whether or not to make these usually-okay changes.

I also have two more patches in the works for next week, which add support
for iterator-based loops and loops over array-like containers.

Thoughts?

-Sam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120803/54e8f776/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: loop-converter.patch
Type: application/octet-stream
Size: 17682 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120803/54e8f776/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: loop-converter-2.patch
Type: application/octet-stream
Size: 31585 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120803/54e8f776/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: loop-converter-3.patch
Type: application/octet-stream
Size: 13025 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120803/54e8f776/attachment-0002.obj>


More information about the cfe-dev mailing list