<div dir="ltr"><div>This will have the observable effect of making cleanups run sooner, right? Can you test for that?</div><div><br></div><div>+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 -fblocks</div><div><br></div><div>If you aren't checking the IR, use -emit-llvm-only to avoid writing to stdout. However, IMO you should be checking the IR here.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 16, 2014 at 3:56 PM, jahanian <span dir="ltr"><<a href="mailto:fjahanian@apple.com" target="_blank">fjahanian@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 style="word-wrap:break-word">Hi John,<div><br></div><div>This test case:</div><div><br></div><div><div style="margin:0px;font-size:11px;font-family:Menlo">id test_dict()</div><div style="margin:0px;font-size:11px;font-family:Menlo">{</div><div style="margin:0px;font-size:11px;font-family:Menlo">        return @{</div><div style="margin:0px;font-size:11px;font-family:Menlo">                @"a": [](){},</div><div style="margin:0px;font-size:11px;font-family:Menlo">                @"b": [](){}</div><div style="margin:0px;font-size:11px;font-family:Menlo">        };</div><div style="margin:0px;font-size:11px;font-family:Menlo">}</div></div><div style="margin:0px;font-size:11px;font-family:Menlo"><br></div><div style="margin:0px;font-size:11px;font-family:Menlo">Crashes in IRGen because ExprWithCleanups for the dummy BlockDecl we use to facilitate lambda to block conversion</div><div style="margin:0px;font-size:11px;font-family:Menlo">is at the wrong place.</div><div style="margin:0px;font-size:11px;font-family:Menlo">This happens because a lambda expression is considered a full expression so it calls MaybeCreateExprWithCleanups</div><div style="margin:0px;font-size:11px;font-family:Menlo">(see <span style="color:rgb(79,129,135)">Sema</span>::BuildBlockForLambdaConversion).</div><div style="margin:0px;font-size:11px;font-family:Menlo">which ends up adding the clean up code for the BlockDecl of the first lambda to the expression for the 2nd lambda!</div><div style="margin:0px;font-size:11px;font-family:Menlo"><br></div><div style="margin:0px;font-size:11px;font-family:Menlo">Ideally, MaybeCreateExprWithCleanups should be called when the entire dictionary literal is seen. But in this case,</div><div style="margin:0px;font-size:11px;font-family:Menlo">this does not happen. Attached patch fixes this by making sure that after ‘every’ parse of the ‘value’ expression</div><div style="margin:0px;font-size:11px;font-family:Menlo">MaybeCreateExprWithCleanups is called. This, in effect, assumes that the ‘value’ literal is a full expression.</div><div style="margin:0px;font-size:11px;font-family:Menlo">I don’t know the ramification of this change in the common case as couple of non-lambda literal tests broke.</div><div style="margin:0px;font-size:11px;font-family:Menlo">(it now generates the none-exc version of call instead of exc versions in couple of places).</div><div style="margin:0px;font-size:11px;font-family:Menlo"><br></div><div style="margin:0px;font-size:11px;font-family:Menlo">Please review. Let me know if you need additional info.</div><div style="margin:0px;font-size:11px;font-family:Menlo"><br></div><div style="margin:0px;font-size:11px;font-family:Menlo">- Thanks, Fariborz</div><div style="margin:0px;font-size:11px;font-family:Menlo"><br></div><div style="margin:0px;font-size:11px;font-family:Menlo"></div></div><br><div style="word-wrap:break-word"><div style="margin:0px;font-size:11px;font-family:Menlo"></div></div>
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div>