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

Pierre Habouzit madcoder at madism.org
Sat Oct 2 01:08:52 PDT 2010


On Sat, Oct 02, 2010 at 09:19:11AM +0200, Pierre Habouzit wrote:
> 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 ?

For example, it could be the two attached patches, the first one being a
rework of my previous patch to simplify a few things, and the second
(re)introducing -rewrite-blocks using the ObjCRewriter with the ObjC
rewriting actually disabled.

I've sent a version of the patch where blank changes are ignored for the
second one for those who want to understand the actual changes it does.
-- 
·O·  Pierre Habouzit
··O                                                madcoder at debian.org
OOO                                                http://www.madism.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Try-to-make-rewrite-objc-result-buildable-by-a-C-com.patch
Type: text/x-diff
Size: 7689 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20101002/f1376317/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Introduce-rewrite-blocks.patch
Type: text/x-diff
Size: 24364 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20101002/f1376317/attachment-0001.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Introduce-rewrite-blocks.IGNORE_BLANKS.patch
Type: text/x-diff
Size: 13946 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20101002/f1376317/attachment-0002.patch>


More information about the cfe-dev mailing list