[PATCH] D18139: [Cxx1z] Implement Lambda Capture of *this by Value as [=, *this] (P0018R3)

Faisal Vali via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 13 21:02:20 PDT 2016


faisalv created this revision.
faisalv added a reviewer: rsmith.
faisalv added a subscriber: cfe-commits.

Implement lambda capture of *this.

struct A {
  int d = 10;
  auto foo() { return [*this] (auto a) mutable { d+=a; return d; }; }
};
auto L = A{}.foo(); // A{}'s lifetime is gone.

// Below is still ok, because *this was captured by value.
assert(L(10) == 20);
assert(L(100) == 120);




http://reviews.llvm.org/D18139

Files:
  README.txt
  include/clang/AST/LambdaCapture.h
  include/clang/Basic/Lambda.h
  include/clang/Sema/ScopeInfo.h
  include/clang/Sema/Sema.h
  lib/AST/ExprCXX.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  test/CodeGenCXX/cxx1z-lambda-star-this.cpp
  test/SemaCXX/cxx1z-lambda-star-this.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18139.50568.patch
Type: text/x-patch
Size: 22083 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160314/f29d8a4d/attachment-0001.bin>


More information about the cfe-commits mailing list