[cfe-dev] Clang Tool: rewrite ObjCMessageExpr

PavelKatunin wk.katunin at gmail.com
Fri Dec 6 00:04:16 PST 2013

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.

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)?

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.

More information about the cfe-dev mailing list