<br><br><div class="gmail_quote">On Wed, Mar 23, 2011 at 10:42 PM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com">rjmccall@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Mar 23, 2011, at 6:56 PM, Abhishek Kulkarni wrote:<br>
> Why are blocks excluded when printing out the AST? Is it a bug?<br>
<br>
</div>Yes.<br>
<div class="im"><br>
> In any case, is there a quick way to dump the blocks-specific generated code (__block_invoke_1, __block_literal_1 etc.)?<br>
<br>
</div>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.<br>
</blockquote><div><br></div><div>Yes, I figured. But thanks, -rewrite-objc gives a good sense of what's going on.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im"><br>
> Finally, is there a way to reach a block's imported variables without modifying the compiler?<br>
<br>
</div>If you have the AST, this is the block decl's "captures" list.<br>
<br>
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.<br>

<font color="#888888"><br></font></blockquote><div><br></div><div>Sorry for not being clear -- I meant to ask if there is a way to inspect the closure's data at runtime. If I have the block pointer, can I get the values of the imported variables that the block encapsulates? I have been looking at the blocks runtime that comes with compiler-rt and it is not clear how the imported variables are laid out within the block's descriptor.</div>
<div><br></div><div>Abhishek</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><font color="#888888">
John.<br>
</font></blockquote></div><br>