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

jahanian fjahanian at apple.com
Tue Sep 16 15:56:37 PDT 2014


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140916/8f7ec781/attachment.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch.txt
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140916/8f7ec781/attachment.txt>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140916/8f7ec781/attachment-0001.html>


More information about the cfe-commits mailing list