[cfe-dev] Rewriting function calls

Manuel Klimek klimek at google.com
Fri Dec 7 06:59:05 PST 2012


Imagine you have a 2-arg join(a, join(b, join(c, d)))

Now you get C++11 so you implement a fancy n-arg one, and want to simplify
all your code. Thus, you'll want
join(a, b, c, d) as the result.
Now this would work as a source location mapping preserving transformation
of the following steps:
1. join(a, join(b, c, d))
2. join(a, b, c, d)

In general, the Rewriter is able to keep mappings through rewrites, but I
don't know how far this would work on this example...

Cheers,
/Manuel



On Fri, Dec 7, 2012 at 3:27 PM, Vane, Edwin <edwin.vane at intel.com> wrote:

>  Can you give an example of what you mean by a recursively applicable
> replacement?****
>
> ** **
>
> *From:* cfe-dev-bounces at cs.uiuc.edu [mailto:cfe-dev-bounces at cs.uiuc.edu] *On
> Behalf Of *Manuel Klimek
> *Sent:* Friday, December 07, 2012 2:15 AM
> *To:* qiuyin at gmail.com
> *Cc:* cfe-dev at cs.uiuc.edu
> *Subject:* Re: [cfe-dev] Rewriting function calls****
>
> ** **
>
> On Fri, Dec 7, 2012 at 6:34 AM, qiuyin at gmail.com <qiuyin at gmail.com> wrote:
> ****
>
> Hi there,
>
> 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?****
>
>  ** **
>
> 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 :)****
>
> ** **
>
> The easy workaround is to do one non-overlapping refactoring at a time
> (that has worked every time so far for us)[****
>
> ** **
>
> Cheers,****
>
> /Manuel****
>
>  ****
>
>
> Thanks!
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev****
>
>  ** **
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121207/05f00206/attachment.html>


More information about the cfe-dev mailing list