<div style="font-family: arial, helvetica, sans-serif; font-size: 10pt"><div dir="ltr">Imagine you have a 2-arg join(a, join(b, join(c, d)))<div><br></div><div>Now you get C++11 so you implement a fancy n-arg one, and want to simplify all your code. Thus, you'll want</div>
<div>join(a, b, c, d) as the result.</div><div>Now this would work as a source location mapping preserving transformation of the following steps:</div><div>1. join(a, join(b, c, d))<br><div>2. join(a, b, c, d)<br></div></div>
<div><br></div><div style>In general, the Rewriter is able to keep mappings through rewrites, but I don't know how far this would work on this example...</div><div style><br></div><div style>Cheers,</div><div style>/Manuel</div>
<div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Dec 7, 2012 at 3:27 PM, Vane, Edwin <span dir="ltr"><<a href="mailto:edwin.vane@intel.com" target="_blank">edwin.vane@intel.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Can you give an example of what you mean by a recursively applicable replacement?<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> <a href="mailto:cfe-dev-bounces@cs.uiuc.edu" target="_blank">cfe-dev-bounces@cs.uiuc.edu</a> [mailto:<a href="mailto:cfe-dev-bounces@cs.uiuc.edu" target="_blank">cfe-dev-bounces@cs.uiuc.edu</a>]
<b>On Behalf Of </b>Manuel Klimek<br>
<b>Sent:</b> Friday, December 07, 2012 2:15 AM<br>
<b>To:</b> <a href="mailto:qiuyin@gmail.com" target="_blank">qiuyin@gmail.com</a><br>
<b>Cc:</b> <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<b>Subject:</b> Re: [cfe-dev] Rewriting function calls<u></u><u></u></span></p><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">On Fri, Dec 7, 2012 at 6:34 AM,
<a href="mailto:qiuyin@gmail.com" target="_blank">qiuyin@gmail.com</a> <<a href="mailto:qiuyin@gmail.com" target="_blank">qiuyin@gmail.com</a>> wrote:<u></u><u></u></span></p>
<div>
<div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">Hi there,<br>
<br>
I am thinking about reverse the order of arguments in a call expression with clang. I'm leveraging the refactoring tool and the AST matcher framework. I use a matcher to find those calls i'm interested in, rewrite the expr, and  insert one replacement. Things
 go tricky for nested calls. Because the refactoring tool applies replacements one by one, and order adjustment does not change the total text length, one replacement could overwrite prior changes. Do i have to implement my own replacement applying algo (i'm
 thinking about adding source range references to a replacement object, and applying them recursively), or is there a simple and better way to do this?<u></u><u></u></span></p>
</blockquote>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif""><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">The problem is that I think the problem is not solvable in general - there is a class of replacements that's recursively applicable though. I think it makes sense to add support
 for those in the refactoring library. I have no clue yet how to do that though :)<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif""><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">The easy workaround is to do one non-overlapping refactoring at a time (that has worked every time so far for us)[<u></u><u></u></span></p>

</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif""><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">Cheers,<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">/Manuel<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif""> <u></u><u></u></span></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif""><br>
Thanks!<br>
<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><u></u><u></u></span></p>
</blockquote>
</div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif""><u></u> <u></u></span></p>
</div>
</div>
</div>
</div></div></div>
</div>

</blockquote></div><br></div></div>