Commit Graph

10 Commits

Author SHA1 Message Date
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Jordan Rose
772a124b63 Compute captures after all bodies have been type-checked, as a separate pass.
We already have the restriction that captures can't be computed until
everything is type-checked, but previously we tried to compute captures
/immediately/ after a closure was type-checked. Unfortunately, we either
type-checked too early (before @noescape was propagated onto multi-statement
closures) or too late (trying to compute autoclosure captures at the point
the autoclosure was introduced).

Now, all closure captures are computed after type-checking, and local
function captures as well. They also more consistently reuse the capture
list of nested closures/functions. Because captures can be computed on
demand, there is now a flag on CaptureInfo for whether we've computed
captures yet. Note that some functions will never have captures computed,
namely those that are not in a local context.

rdar://problem/19956242

Swift SVN r25776
2015-03-05 02:33:37 +00:00
Ted Kremenek
9e7471d68b Revert "Revert "Rework processing of @noescape closures a bit to fix rdar://19981118:""
Turns out llvm::DataLayoutPass is used in other places, so the bots are still unhappy.
Re-applying the original change so we can fix the problem holistically.

Swift SVN r25761
2015-03-04 20:15:45 +00:00
Ted Kremenek
6781ac7bec Revert "Rework processing of @noescape closures a bit to fix rdar://19981118:"
This is breaking the testing bot because DataLayoutPass was just removed from LLVM trunk.
Chris is the best one to fix this change, but we need to get the bots green.

Swift SVN r25760
2015-03-04 20:03:33 +00:00
Chris Lattner
ab43e444d6 Rework processing of @noescape closures a bit to fix rdar://19981118:
- Have Sema, not SILGen decide if a vardecl can be captured by address
  instead of by-box.  This is a non-local property that is best computed
  during capture set formation.  Sema captures this as a bit on the new
  CapturedValue entry.
- Rework some diagnostic emission to centralize a class of noescape 
  diagnostics in capture set calculation.  Previously, funcdecl closures
  produced their diagnostics there, but ClosureExprs produced them in
  MiscDiagnostics (NFC for this part).

This fixes <rdar://problem/19981118> Swift 1.2 beta 2: Closures nested in @noescape closures copy, rather than reference, captured vars.



Swift SVN r25759
2015-03-04 19:30:36 +00:00
Chris Lattner
83009065f8 - Rework computation of "direct" closure capture formation to be based on whether
the DeclRefExpr's access semantics is "direct to storage" instead of basing it
  on the weird special case we were using before.
- Change AST dumper to print the "direct" flag.

NFC.



Swift SVN r25749
2015-03-04 06:17:40 +00:00
Chris Lattner
3489840b8d rework our representation of capture lists to compute the "isDirect" bit up front
when computing the list.  This simplifies getLocalCaptures to *just* filter out
global captures, and paves the way for other enhancements.  NFC.


Swift SVN r25739
2015-03-04 01:56:48 +00:00
Chris Lattner
bc005219d1 Implement most of support for properties in function scope, part of rdar://15922884.
Most of the complexity here is teaching SILGen how to handle closed-over direct 
accesses to observing properties, since all of the getter/setter/willSet/didSet
members of the property are actually full closures when in a function body.

We generate correct but really terrible code here, since the setter captures the
willset/didset members themselves.  I'm not worrying about the performance of 
this construct though, functionality is what matters.


Swift SVN r13778
2014-02-11 06:23:14 +00:00
Chris Lattner
74bf9c98c6 change the CaptureInfo::getLocalCaptures() method to return a SmallVector
by reference, avoiding allocating heap memory.



Swift SVN r8275
2013-09-16 15:25:48 +00:00
Dmitri Hrybenko
5ac875e5dc Add CaptureInfo class that manages capture lists
Swift SVN r8234
2013-09-14 00:22:44 +00:00