[cfe-users] How do I output Clang's source code transition of Blocks?

Alp Toker alp at nuanti.com
Tue May 27 11:18:21 PDT 2014


Hi Richard,

You can find the closest thing to that, clang's source-level blocks 
translator, in RewriteObjC.cpp.

As Jordan points out, the main compilation path in clang doesn't use 
source-level translation.

The aforementioned rewrite facility was developed in order to target 
Objective-C code to MSVC back before clang itself was viable on Windows.

Alp.



On 14/05/2014 01:40, Richard Catlin wrote:
> For example, the Block Implementation Specification says
>
> ^ { printf("hello world\n"); }
>
> is translated to
>
> struct __block_literal_1 {
> void *isa;
> int flags;
> int reserved;
> void (*invoke)(struct __block_literal_1 *);
> struct __block_descriptor_1 *descriptor;
> };
> void __block_invoke_1(struct __block_literal_1 *_block) {
> printf("hello world\n");
> }
> static struct __block_descriptor_1 {
> unsigned long int reserved;
> unsigned long int Block_size;
> } __block_descriptor_1 = { 0, sizeof(struct __block_literal_1), 
> __block_invoke_1 };
>
> struct __block_literal_1 _block_literal = {
> &_NSConcreteStackBlock,
> (1<<29), <uninitialized>,
> __block_invoke_1,
> &__block_descriptor_1
> };
>
> Thanks for any help.
> Richard Catlin
>
>
>
> _______________________________________________
> cfe-users mailing list
> cfe-users at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users

-- 
http://www.nuanti.com
the browser experts




More information about the cfe-users mailing list