Fix <rdar://problem/18199087> DI doesn't catch use of super properties lexically inside super.init call

When analyzing a super.init call, we have several instructions involved including an upcast
to the parent type and an applyinst to call super.init.  DI was using the location of the upcast
as the point at which it modeled the super.init requirement, not at the point of the applyinst.  This
meant that code like:

 %x = upcast self to basetype
 ... stuff ...
 apply super.init(%x)

would not catch invalid uses of super in the "stuff" range, because DI thought that super.init was
called at the upcast.  Fix this by using the apply as the super.init use, not the upcast.




Swift SVN r22101
This commit is contained in:
Chris Lattner
2014-09-18 21:52:11 +00:00
parent 5c85fa5b7d
commit 160438e14e
4 changed files with 84 additions and 24 deletions

View File

@@ -848,7 +848,7 @@ void LifetimeChecker::handleLoadUseFailure(const DIMemoryUse &Use,
/// handleSuperInitUse - When processing a 'self' argument on a class, this is
/// a call to super.init.
void LifetimeChecker::handleSuperInitUse(const DIMemoryUse &InstInfo) {
UpcastInst *Inst = cast<UpcastInst>(InstInfo.Inst);
auto *Inst = cast<ApplyInst>(InstInfo.Inst);
// Determine the liveness states of the memory object, including the
// super.init state.