[cfe-dev] inspecting emitted blocks code

John McCall rjmccall at apple.com
Wed Mar 23 19:42:35 PDT 2011


On Mar 23, 2011, at 6:56 PM, Abhishek Kulkarni wrote:
> Why are blocks excluded when printing out the AST? Is it a bug?

Yes.

> In any case, is there a quick way to dump the blocks-specific generated code (__block_invoke_1, __block_literal_1 etc.)?

Blocks code is generated by directly synthesizing the appropriate LLVM IR, not by constructing a C-like syntax tree and then emitting that.  The Objective-C rewriter is capable of doing that, although it doesn't make any guarantee of being perfectly consistent with the code that IR gen would emit.

> Finally, is there a way to reach a block's imported variables without modifying the compiler?

If you have the AST, this is the block decl's "captures" list.

I don't know what you mean by "without modifying the compiler", but we strongly encourage people who are interested in analyzing C/C++ programs to work with our AST (or LLVM IR, as appropriate) instead of exporting the information into some other format which is pretty much inevitably going to be a lesser cousin to the AST.

John.



More information about the cfe-dev mailing list