[cfe-dev] -rewrite-objc and typeof (Was: -rewrite-objc, C and blocks)

Pierre Habouzit madcoder at madism.org
Sat Oct 2 00:19:11 PDT 2010


On Fri, Oct 01, 2010 at 02:14:09PM -0700, jahanian wrote:
> 
> On Oct 1, 2010, at 1:42 PM, Pierre Habouzit wrote:
> 
> > 
> > While I'm at it, the objc rewriter tries hard to rewrite typeof() for a
> > reason that eludes me.  Given that typeof() is often used inside macros,
> > and that rewriting inside macros may not work (that I can understand
> > ;p), this is really painful.
> 
> We needed to support rewriting of __typeof because of our requirements.
> There is a test case under Rewrite/rewrite-typeof.mm which specifically
> tests this.

To be frank it still doesn't explain why you need it at all, but fine :)

> This is one other reason to have a separate rewriter  without baggage
> associated with our specific needs.

Well, I've made the work of taking the block rewriting code from
RewriteObjC.cpp, it's huge, and I'm uncomfortable duplicating that
amount of code.

So what is the best approach, is it writing a new RewriteBlocks class
that RewriteObjC would inherit from (but it's a very huge work) or
simply make RewriteObjC have a "bool RewriteBlocksOnly" setting that is
selected whether it's called from -rewrite-objc or -rewrite-blocks on
the command line, and that would affect how code is generated ?

I'd rather go for the latter that is simpler, as mostly for now, it will
just disable the typeof rewriting, simplify the preamble (the objc stuff
isn't required), and keep my previous patch so that the generated code
still works when compiled with a c++ compiler.

Would that be acceptable ?
-- 
·O·  Pierre Habouzit
··O                                                madcoder at debian.org
OOO                                                http://www.madism.org



More information about the cfe-dev mailing list