[cfe-dev] Clang Tool: rewrite ObjCMessageExpr

Manuel Klimek klimek at google.com
Sat Dec 7 07:16:42 PST 2013


On Fri, Dec 6, 2013 at 9:04 AM, PavelKatunin <wk.katunin at gmail.com> wrote:

> I want to rewrite all messages in my code, I need replace only selectors,
> but
> I need be able to replace nested expressions f. e. :
>
> [super foo:[someInstance someMessage:@""] foo2:[someInstance
> someMessage2]];
> I tried do it with clang::Rewriter replaceText and just generate new
> string,
> but there is a problem: It would not be work if I change selectors length,
> because I replace nested messages with those old positions.
>

I don't fully understand what the problem is - can you give an example of
what would happen?


>
> So, I assumed that I need to use clang::Rewriter
> ReplaceStmt(originalStatement, newStatement);
>
> I am using RecursiveASTVisitor to visit all messages, and I want to copy
> those messages objects, and replace selectors:
>
> How can I do that?
>
> I tried use ObjCMessageExpr::Create but there is so meny args, I don't know
> how to get ASTContext &Context and ArrayRef<SourceLocation> SeLocs and Expr
> *Receiver parameters from the original message.
>
> What is the proper way to replace selectors in nested messages using clang
> tool (clang tooling interface)?
>

I'd usually suggest the AST matchers, but you can also use the RAV - the
AST matchers make it a little easier to get all information you need
together...

Cheers,
/Manuel



>
>
>
> --
> View this message in context:
> http://clang-developers.42468.n3.nabble.com/Clang-Tool-rewrite-ObjCMessageExpr-tp4036492.html
> Sent from the Clang Developers mailing list archive at Nabble.com.
> _______________________________________________
> 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/20131207/e9e08afa/attachment.html>


More information about the cfe-dev mailing list