fix <rdar://problem/20608881> DI miscompiles this testcase into a memory leak

When emiting logic for conditional destruction of a variable, we weren't considering
a delegated init as a store to the variable that needed to be tracked.  This caused us
to miscompile situations like this testcase where the self.init was conditional:

struct X {
  var c : C
  init() { c = C()}
  init?(a : Bool) {
    if a { self.init() }
    return nil
  }
}

This was exposed by other work, but needs to be fixed in any case.



Swift SVN r27471
This commit is contained in:
Chris Lattner
2015-04-20 00:26:55 +00:00
parent 86f5396637
commit 17bfa99d89
2 changed files with 43 additions and 9 deletions

View File

@@ -1493,6 +1493,7 @@ SILValue LifetimeChecker::handleConditionalInitAssign() {
// The dynamically unknown case is the interesting one, handle it below.
break;
case DIUseKind::SelfInit:
case DIUseKind::Initialization:
// If this is an initialization of only trivial elements, then we don't
// need to update the bitvector.