faisalv added a comment.

In regards to representing this in the AST - I think (based on precedence) that 
the number of explicit template parameters should be stored in 
LambdaDefinitionData - and the interface exposed through LambdaExpr (where the 
source information of the template parameter list should be stored too i think 
- Richard you agree?).

Also can you add examples of such generic lambdas that are nested within either 
other generic lambdas or templates - and make sure that they 
instantiate/substitute correctly - and that we really don't have to touch the 
template instantiation machinery?

Thanks!



================
Comment at: include/clang/Sema/ScopeInfo.h:955
+  }
+
   // When passed the index, returns the VarDecl and Expr associated
----------------
This function doesn't seem to be called anywhere?


================
Comment at: lib/Parse/ParseExprCXX.cpp:1116
+  if (HasExplicitTemplateParams) {
+    SmallVector<Decl*, 4> TemplateParams;
+    SourceLocation LAngleLoc, RAngleLoc;
----------------
Why not Just use/pass LSI->TemplateParams?


================
Comment at: lib/Sema/SemaLambda.cpp:501
+      LAngleLoc, TParams, RAngleLoc,
+      /*RequiresClause=*/nullptr);
+
----------------
I'm not sure i see the point in creating the template parameter list here and 
returning it, when it's not used anywhere?  The TPL is created and cached in 
GLTemplateParameterList when needed it seems.



================
Comment at: lib/Sema/SemaLambda.cpp:858
+    KnownDependent = CurScope->getTemplateParamParent() != nullptr;
+  }
 
----------------
Hmm - now that you drew my attention to this ;) - I'm pretty sure this is 
broken - but (embarrassingly) it broke back when i implemented generic lambdas 
(and interestingly is less broken w generic lambdas w explicit TPLs) - could I 
ask you to add a FIXME here that states something along the lines of:  

When parsing default arguments that contain lambdas, it seems necessary to know 
whether the containing parameter-declaration clause is that of a template to 
mark the closure type created in the default-argument as dependent.  Using 
template params to detect dependence is not enough for all generic lambdas 
since you can have generic lambdas without explicit template parameters, and 
whose default arguments contain lambdas that should be dependent - and you can 
not rely on the existence of a template parameter scope to detect those cases.  
Consider:
   auto L = [](int I = [] { return 5; }(), auto a) { };  
The above nested closure type (of the default argument) occurs within a 
dependent context and is therefore dependent - but we won't know that until we 
parse the second parameter.  

p.s. I'll try and get around to fixing this if no one else does.



https://reviews.llvm.org/D36527



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to