[PATCH] Step 1: Simple Generic lambda (no captures or nested lambdas)

Richard Smith richard at metafoo.co.uk
Tue Jun 25 12:31:08 PDT 2013


On Wed, Jun 19, 2013 at 7:33 AM, Faisal Vali <faisalv at gmail.com> wrote:
>>
>> I would prefer for the parser to not need to know about the
>> implicitly-generated template parameters, if you can arrange that.
>> Maybe the relevant data can be maintained by Sema in the
>> LambdaScopeInfo?
>>
>
> The LambdaScopeInfo does not get pushed on till the declarator has been parsed.
> Should I create a ParameterClauseInfo object in Sema and add the
> TemplateParameterDepth to it and use it to keep a track of the Invented
> TemplateParameterList too that ActOnStartOfLambdaDefinition can query
> (I wonder if i'll have to prime this properly during the TransformLambdaExpr
> for nested lambdas)?
> Is this the better design?

We should create the LambdaScopeInfo at the end of the
lambda-introducer, rather than waiting until we've parsed the
lambda-declarator. This is also important for init-captures, where we
need to introduce the captures into the scope at the end of the
introducer:

  [x(0)] (decltype(x) p) {} // ok
  [x(0), y(x)] {} // error, 'x' not in scope in initializer of 'y'.

> Also, unlike for the LambdaScopeInfo, I don't think i'll need to
> create a stack of these objects, right?

You would need a stack, in case a generic lambda appears in a default
argument for another generic lambda:

  [] (auto a, int n = [] (auto b) { return b; } (0)) {}



More information about the cfe-commits mailing list