Verify @inout_aliasable captures.

This is currently only done in DiagnoseStaticExclusivity because AllocBoxToStack
doesn't know how to set @noescape function types yet.
This commit is contained in:
Andrew Trick
2018-01-11 01:01:57 -08:00
parent 209cd2e0bf
commit fb42d85dc3
3 changed files with 136 additions and 0 deletions

View File

@@ -234,6 +234,53 @@ SILValue swift::stripBorrow(SILValue V) {
return V;
}
SingleValueInstruction *swift::getSingleValueCopyOrCast(SILInstruction *I) {
if (auto *convert = dyn_cast<ConversionInst>(I))
return convert;
switch (I->getKind()) {
default:
return nullptr;
case SILInstructionKind::CopyValueInst:
case SILInstructionKind::CopyBlockInst:
case SILInstructionKind::BeginBorrowInst:
case SILInstructionKind::BeginAccessInst:
return cast<SingleValueInstruction>(I);
}
}
bool swift::isIncidentalUse(SILInstruction *user) {
switch (user->getKind()) {
default:
return false;
case SILInstructionKind::DebugValueInst:
case SILInstructionKind::EndAccessInst:
case SILInstructionKind::EndBorrowInst:
case SILInstructionKind::EndLifetimeInst:
case SILInstructionKind::FixLifetimeInst:
return true;
}
}
bool swift::onlyAffectsRefCount(SILInstruction *user) {
switch (user->getKind()) {
default:
return false;
case SILInstructionKind::AutoreleaseValueInst:
case SILInstructionKind::DestroyValueInst:
case SILInstructionKind::ReleaseValueInst:
case SILInstructionKind::RetainValueInst:
case SILInstructionKind::StrongReleaseInst:
case SILInstructionKind::StrongRetainInst:
case SILInstructionKind::UnmanagedAutoreleaseValueInst:
case SILInstructionKind::UnmanagedReleaseValueInst:
case SILInstructionKind::UnmanagedRetainValueInst:
case SILInstructionKind::UnownedReleaseInst:
case SILInstructionKind::UnownedRetainInst:
return true;
}
}
namespace {
enum class OwnershipQualifiedKind {