Patch to fix IRGen crash using lambda expression as value in dictionary literal

Reid Kleckner rnk at google.com
Tue Sep 16 16:46:44 PDT 2014


This will have the observable effect of making cleanups run sooner, right?
Can you test for that?

+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s
-fexceptions -std=c++11 -fblocks

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.

On Tue, Sep 16, 2014 at 3:56 PM, jahanian <fjahanian at apple.com> wrote:

> Hi John,
>
> This test case:
>
> id test_dict()
> {
>         return @{
>                 @"a": [](){},
>                 @"b": [](){}
>         };
> }
>
> Crashes in IRGen because ExprWithCleanups for the dummy BlockDecl we use
> to facilitate lambda to block conversion
> is at the wrong place.
> This happens because a lambda expression is considered a full expression
> so it calls MaybeCreateExprWithCleanups
> (see Sema::BuildBlockForLambdaConversion).
> which ends up adding the clean up code for the BlockDecl of the first
> lambda to the expression for the 2nd lambda!
>
> Ideally, MaybeCreateExprWithCleanups should be called when the entire
> dictionary literal is seen. But in this case,
> this does not happen. Attached patch fixes this by making sure that after
> ‘every’ parse of the ‘value’ expression
> MaybeCreateExprWithCleanups is called. This, in effect, assumes that the
> ‘value’ literal is a full expression.
> I don’t know the ramification of this change in the common case as couple
> of non-lambda literal tests broke.
> (it now generates the none-exc version of call instead of exc versions in
> couple of places).
>
> Please review. Let me know if you need additional info.
>
> - Thanks, Fariborz
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140916/f0d83912/attachment.html>


More information about the cfe-commits mailing list