[move-only] Fix emission of addressonly noncopyable setter new values.

NOTE: This does not affect normal parameters since normal parameters that are
noncopyable never have default access semantics since the user is forced to
specify either borrow or consume. This is incontrast to implicit parameters like
the newValue of a setter.

rdar://109726282
This commit is contained in:
Michael Gottesman
2023-05-22 17:54:03 -07:00
parent add598762c
commit 82c645db21
2 changed files with 49 additions and 4 deletions

View File

@@ -552,8 +552,12 @@ public:
substFormalParams.push_back(
pd->toFunctionParam(pd->getType()).getCanonical(nullptr));
};
for (auto paramDecl : *paramList) { addParamDecl(paramDecl); }
if (selfParam) { addParamDecl(selfParam); }
for (auto paramDecl : *paramList) {
addParamDecl(paramDecl);
}
if (selfParam) {
addParamDecl(selfParam);
}
// Initialize the formal parameter generator. Note that this can
// immediately claim lowered parameters.
@@ -795,8 +799,32 @@ private:
loc, value, MarkMustCheckInst::CheckKind::NoConsumeOrAssign);
}
} else {
assert(isa<MarkMustCheckInst>(value) &&
"Should have inserted mark must check inst in EmitBBArgs");
if (auto *fArg = dyn_cast<SILFunctionArgument>(value)) {
switch (fArg->getArgumentConvention()) {
case SILArgumentConvention::Direct_Guaranteed:
case SILArgumentConvention::Direct_Owned:
case SILArgumentConvention::Direct_Unowned:
case SILArgumentConvention::Indirect_Inout:
case SILArgumentConvention::Indirect_Out:
case SILArgumentConvention::Indirect_InoutAliasable:
case SILArgumentConvention::Pack_Inout:
case SILArgumentConvention::Pack_Guaranteed:
case SILArgumentConvention::Pack_Owned:
case SILArgumentConvention::Pack_Out:
llvm_unreachable("Should have been handled elsewhere");
case SILArgumentConvention::Indirect_In:
value = SGF.B.createMarkMustCheckInst(
loc, value,
MarkMustCheckInst::CheckKind::ConsumableAndAssignable);
break;
case SILArgumentConvention::Indirect_In_Guaranteed:
value = SGF.B.createMarkMustCheckInst(
loc, value, MarkMustCheckInst::CheckKind::NoConsumeOrAssign);
}
} else {
assert(isa<MarkMustCheckInst>(value) &&
"Should have inserted mark must check inst in EmitBBArgs");
}
}
break;
case ValueOwnership::InOut: