[PATCH] Implement transformations of non-capturing nested lambdas.

Doug Gregor dgregor at apple.com
Tue Oct 22 22:39:10 PDT 2013

Comment at: lib/Sema/SemaTemplateInstantiate.cpp:933
@@ +932,3 @@
+      //  - In the generic lambda case, we set the NewTemplate to be considered
+      //    an "instantiation" of the OldTemplate.
+      // See the documentation and use of get/setInstantiationOfMemberFunction
Faisal Vali wrote:
> Doug Gregor wrote:
> > I love comments, but I don't think a complete discussion of how primary templates and specializations are wired together is necessary here. This last bullet is the important part for what we're doing here.
> So I should replace the entire block above with:
> //  In the non-generic lambda case we set the NewCallOperator to be considered
> //  an instantiation of the OldCallOperator.
> //  In the generic lambda case, we set the NewTemplate to be considered 
> //  an "instantiation" of the OldTemplate.
That'd be perfect, thanks!

Comment at: lib/Sema/TreeTransform.h:8299
@@ +8298,3 @@
+  if (OrigTPL) 
+    NewTPL = getDerived().TransformTemplateParameterList(OrigTPL);
+  LSI->GLTemplateParameterList = NewTPL;
Faisal Vali wrote:
> Doug Gregor wrote:
> > Don't we need to check whether NewTPL null after this, in case the transformation of the template parameter list failed?
> Not really, since whether it is null or not is checked by the Sema::lambda clan.  But now that you draw my attention to it, I guess I could replace these 5 lines with this one:
> LSI->GLTemplateParameterList = getDerived().TransformTemplateParameterList(E->getTemplateParameterList());
I guess it was a question of whether we're less likely to break invariants (i.e., crash) if we did an early exit after failing to instantiate the template parameter list. Does one of your tests trigger a failure during template parameter list substitution?


More information about the cfe-commits mailing list