[cfe-dev] Parsing objective-c message expressions

steve naroff snaroff at apple.com
Tue Jul 29 09:53:31 PDT 2008

On Jul 29, 2008, at 8:11 AM, Rajesh Karmani wrote:

> Hi,
> I have just started looking at Clang and found it to be a great tool.
> I also came across the RewriteObjc module and wanted to play around  
> with
> how the Objective-C messages are "rewritten".
> I have not been able to figure out how an assignment statement like:
> c = [obj execute];
> is parsed in Clang (what functions are called?). I would like to  
> rewrite
> such statements differently from
> [obj execute];
> where nothing is being returned. Could someone please guide me which
> parts of code should I be looking at?

Here is a brief example...

snaroffBook$ cat xx.m
#import <Foundation/NSObject.h>

void f(NSObject *m) {
   NSObject* c = [m execute];

snaroffBook$ ../../Debug/bin/clang -rewrite-objc xx.m

#include <Foundation/NSObject.h>

void f(NSObject *m) {
   NSObject* c = ((id (*)(id, SEL, ...))(void *)objc_msgSend)((id)m,  

The actual rewriter code is in RewriteObjC.cpp.


> regards,
> rajesh
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

More information about the cfe-dev mailing list