[semantic-sil] Ensure that all function arguments have the correct ownership kind and create a verifier check that this is preserved.

rdar://29791263
This commit is contained in:
Michael Gottesman
2017-01-09 13:34:25 -08:00
parent 31309f436b
commit e2273ce9dc
2 changed files with 18 additions and 2 deletions

View File

@@ -124,7 +124,11 @@ void SILBasicBlock::cloneArgumentList(SILBasicBlock *Other) {
SILFunctionArgument *SILBasicBlock::createFunctionArgument(SILType Ty,
const ValueDecl *D) {
assert(isEntry() && "Function Arguments can only be in the entry block");
auto OwnershipKind = ValueOwnershipKind::Any;
SILFunction *Parent = getParent();
auto OwnershipKind = ValueOwnershipKind(
Parent->getModule(), Ty,
Parent->getLoweredFunctionType()->getSILArgumentConvention(
getNumArguments()));
return new (getModule()) SILFunctionArgument(this, Ty, OwnershipKind, D);
}