[cfe-users] How do I output Clang's source code transition of Blocks?
Jordan Rose
jordan_rose at apple.com
Tue May 27 09:03:32 PDT 2014
Clang does not actually perform a source translation for block literals. Instead, it generates code similar to what would have been generated had the user written the equivalent code.
There are many reasons why actually implementing this feature via source code translation would be difficult, but probably the most compelling is performance: there is really no reason for the compiler to go through all the work of parsing new source code when it already knows that it represents a block.
What do you actually need this for?
Jordan
On May 13, 2014, at 15:40 , Richard Catlin <richard.m.catlin at gmail.com> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20140527/533e34e0/attachment.html>
More information about the cfe-users
mailing list