[sil] Delete SILInstruction::removeFromParent().

This is a very easily misused API since it allows for users to leak instructions
if they are not careful. This commit removes this API and replaces the small
number of uses of this API with higher level APIs that accomplish the same task
without using removeFromParent(). There were no API users that specifically
required removeFromParent.

An example of one way we were using removeFromParent is to move a SILInstruction
to the front of a block. That does not require exposing an API like
removeFromParent()... we can just create a higher level API like the one added
in this commit: SILInstruction::moveFront(SILBasicBlock *).

rdar://31276565
This commit is contained in:
Michael Gottesman
2017-06-06 10:38:09 -07:00
parent ffd9e952d8
commit f85da6860a
5 changed files with 14 additions and 23 deletions

View File

@@ -2237,8 +2237,7 @@ handleConditionalDestroys(SILValue ControlVariableAddr) {
}
case DIKind::Yes:
// super.init() already called, just release the value.
Release->removeFromParent();
B.getInsertionBB()->insert(B.getInsertionPoint(), Release);
Release->moveBefore(&*B.getInsertionPoint());
continue;
}
}