[cfe-dev] Evaluating lambda function return type

Nikola Smiljanic popizdeh at gmail.com
Thu Sep 18 14:59:03 PDT 2014


Lambda is built as a class with function call operator, not a function.
Have a look at Sema::startLambdaDefinition, I think it does what you're
interested in. In the example you gave 'auto f' is bound to the lambda
expression itself, not its return type. You'll have to call it to get the
return type 'int x = f()'.


On Thu, Sep 18, 2014 at 2:35 PM, Amila Jayasekara <thejaka.amila at gmail.com>
wrote:

> Hi All,
>
> In an input program I have following code;
>
> auto f = [&z](int y)->int {
>
>       return 5 * y + z;
>
> }
>
> I am trying to figure out where we build the type of the lambda expression
> (i.e. lambda is a function that has type, int->int)
>
> So far I checked in "Sema::ActOnStartOfLambdaDefinition" (in
> SemaLambda.cpp). But still I am unable to figure out the exact location
> where we build the type of the lambda expression.
>
> Can someone please help me to figure out where clang build the return type
> for lambda functions ?
>
> Also where do we bind "f" to the return type of lambda function ?
>
> Thank you
>
> Regards
>
> -Thejaka Amila
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140919/a9469b79/attachment.html>


More information about the cfe-dev mailing list