[PATCH] Implement capturing for generic lambdas

Faisal Vali faisalv at yahoo.com
Wed Nov 6 07:36:40 PST 2013



================
Comment at: lib/Sema/SemaExpr.cpp:12016-12019
@@ +12015,6 @@
+  if (LambdaScopeInfo *LSI = getCurLambda()) {
+    for (int I = LSI->getNumPotentialCaptures(); I--; ) {
+      Expr *ExprVarUsedIn = 0; 
+      VarDecl *Var = 0;
+      LSI->getPotentialCapture(I, Var, ExprVarUsedIn);
+      if (Var && E->IgnoreParens() == ExprVarUsedIn) {
----------------
Faisal Vali wrote:
> Richard Smith wrote:
> > Looks like an off-by-one error here? Should `I` start at `NumPotentialCaptures - 1`?
> It shouldn't be off by one - we start at NumPotentialCaptures, then decrement I right away and if we start at 1 or 0,  the body should never be entered (postincrement).  But I can use a different iteration scheme if you want.
Er that's - if we start at 1, we enter the body for the '0' th case, but do not enter if the num of captures is 0.


http://llvm-reviews.chandlerc.com/D2035



More information about the cfe-commits mailing list