Fix several incorrect uses of ApplySite::getArgumentConvention.

At least most of these were latent bugs since the code was
unreachable in the PartialApply case. But that's no excuse to misuse
the API.

Also, whenever referring to an integer index, be explicit about
whether it is an applied argument or callee argument.
This commit is contained in:
Andrew Trick
2018-07-20 14:25:53 -07:00
parent 401be14483
commit 89ed064808
7 changed files with 19 additions and 39 deletions

View File

@@ -1936,11 +1936,6 @@ public:
return OperandValueArrayRef(opsWithoutSelf);
}
/// Return the SILArgumentConvention for the given applied argument index.
SILArgumentConvention getArgumentConvention(unsigned index) const {
return getSubstCalleeConv().getSILArgumentConvention(index);
}
Optional<SILResultInfo> getSingleResult() const {
auto SubstCallee = getSubstCalleeType();
if (SubstCallee->getNumAllResults() != 1)
@@ -7665,7 +7660,7 @@ public:
}
/// Return the applied argument index for the given operand.
unsigned getArgumentIndex(const Operand &oper) const {
unsigned getAppliedArgIndex(const Operand &oper) const {
assert(oper.getUser() == Inst);
assert(isArgumentOperand(oper));
@@ -7704,21 +7699,16 @@ public:
/// Note: Passing an applied argument index into SILFunctionConvention, as
/// opposed to a function argument index, is incorrect.
unsigned getCalleeArgIndex(const Operand &oper) const {
return getCalleeArgIndexOfFirstAppliedArg() + getArgumentIndex(oper);
return getCalleeArgIndexOfFirstAppliedArg() + getAppliedArgIndex(oper);
}
/// Return the SILArgumentConvention for the given applied argument operand.
SILArgumentConvention getArgumentConvention(Operand &oper) const {
unsigned calleeArgIdx =
getCalleeArgIndexOfFirstAppliedArg() + getArgumentIndex(oper);
getCalleeArgIndexOfFirstAppliedArg() + getAppliedArgIndex(oper);
return getSubstCalleeConv().getSILArgumentConvention(calleeArgIdx);
}
// FIXME: This is incorrect. It will be removed in the next commit.
SILArgumentConvention getArgumentConvention(unsigned index) const {
return getSubstCalleeConv().getSILArgumentConvention(index);
}
/// Return true if 'self' is an applied argument.
bool hasSelfArgument() const {
switch (Inst->getKind()) {