[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas

Faisal Vali via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 21 08:34:01 PDT 2017


faisalv added inline comments.


================
Comment at: lib/Parse/ParseExprCXX.cpp:1116
+  if (HasExplicitTemplateParams) {
+    SmallVector<Decl*, 4> TemplateParams;
+    SourceLocation LAngleLoc, RAngleLoc;
----------------
hamzasood wrote:
> faisalv wrote:
> > hamzasood wrote:
> > > faisalv wrote:
> > > > Why not Just use/pass LSI->TemplateParams?
> > > I thought that Parser and Sema stay separate, and communicate through various ActOn functions? Directly accessing LSI would violate that.
> > Aah yes - you're right.  Still it does seem a little wasteful to create two of those (and then append).  What are your thoughts about passing the argument by (moved from) value, and then swapping their guts within ActOn (i..e value-semantics) ?  (I suppose the only concern would be the small array case - but i think that would be quite easy for any optimizer to inline).   
> > 
> I don't think a SmallVectorImpl can be passed by value.
> 
> So to make that work, the function would either needed to be templated (SmallVector<Decl*, I>) or only accept a SmallVector<Decl*, 4>. And I don't think either of those options are worthwhile.
OK - add a FIXME that alerts folks that we currently make two copies of this and ideally we shouldn't need to.


https://reviews.llvm.org/D36527





More information about the cfe-commits mailing list