llvm-project/clang/www
Faisal Vali dc6b596ebb [Cxx1z] Implement Lambda Capture of *this by Value as [=,*this] (P0018R3)
Implement lambda capture of *this by copy.
For e.g.:
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);

If the capture was implicit, or [this] (i.e. *this was captured by reference), this code would be otherwise undefined.

Implementation Strategy:
  - amend the parser to accept *this in the lambda introducer
  - add a new king of capture LCK_StarThis
  - teach Sema::CheckCXXThisCapture to handle by copy captures of the
    enclosing object (i.e. *this)
  - when CheckCXXThisCapture does capture by copy, the corresponding 
    initializer expression for the closure's data member 
    direct-initializes it thus making a copy of '*this'.
  - in codegen, when assigning to CXXThisValue, if *this was captured by 
    copy, make sure it points to the corresponding field member, and
    not, unlike when captured by reference, what the field member points
    to.
  - mark feature as implemented in svn

Much gratitude to Richard Smith for his carefully illuminating reviews!   

llvm-svn: 263921
2016-03-21 09:25:37 +00:00
..
analyzer [analyzer] Add --force-analyze-debug-code option to scan-build 2016-02-18 11:08:46 +00:00
demo Update mailing list references to lists.llvm.org 2015-08-05 03:55:23 +00:00
OpenProjects.html Update some stuff on the open projects page to reflect things we've already done. 2013-04-20 16:20:44 +00:00
UniversalDriver.html
builtins.py
carbon-compile.png
clang_video-05-25-2007.html
clang_video-07-25-2007.html
comparison.html Fix grammar. 2015-12-16 00:19:23 +00:00
compatibility.html Switch C compilations to C11 by default. 2014-10-20 23:26:58 +00:00
content.css
cxx_compatibility.html
cxx_dr_status.html Implement the likely resolution of core issue 253. 2016-02-19 01:52:46 +00:00
cxx_status.html [Cxx1z] Implement Lambda Capture of *this by Value as [=,*this] (P0018R3) 2016-03-21 09:25:37 +00:00
diagnostics.html Fix typo in CSS class name. 2014-02-03 07:02:19 +00:00
favicon.ico
feature-compile1.png
feature-compile2.png
feature-memory1.png
features.html Remove deprecated information about performances: 2014-04-27 14:54:11 +00:00
get_involved.html Update mailing list references to lists.llvm.org 2015-08-05 03:55:23 +00:00
get_started.html Remove references to autotools build. 2016-01-30 00:54:42 +00:00
hacking.html Tweak documentation. 2014-06-12 21:15:10 +00:00
index.html Test commit, fixed "clang" to "Clang" in docs 2016-02-10 21:06:10 +00:00
libstdc++4.4-clang0x.patch
libstdc++4.6-clang11.patch
libstdc++4.7-clang11.patch
make_cxx_dr_status Update make_cxx_dr_status after the 3.8 branch. 2016-01-13 22:51:59 +00:00
menu.css Fix a menu issue. patch by Vassil Vassilev 2015-03-09 09:09:55 +00:00
menu.html.incl Update mailing list references to lists.llvm.org 2015-08-05 03:55:23 +00:00
related.html Add a link to the DXR project 2015-10-29 17:20:17 +00:00
robots.txt