[PATCH] D30327: [Sema] Improve side effect checking for unused-lambda-capture warning

Malcolm Parsons via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 28 01:23:34 PST 2017


malcolm.parsons added a comment.

I found this FIXME comment in `Expr::HasSideEffects()`:

  case LambdaExprClass: {
    const LambdaExpr *LE = cast<LambdaExpr>(this);
    for (LambdaExpr::capture_iterator I = LE->capture_begin(),
                                      E = LE->capture_end(); I != E; ++I)
      if (I->getCaptureKind() == LCK_ByCopy)
        // FIXME: Only has a side-effect if the variable is volatile or if
        // the copy would invoke a non-trivial copy constructor.
        return true;
    return false;
  }

It seems a shame not to fix this now, but I don't think I can call Sema code from AST code, and my `CaptureHasSideEffects()` depends on `Sema::getCurrentThisType()`.

Any ideas?


https://reviews.llvm.org/D30327





More information about the cfe-commits mailing list