[NFC] Change forEachFunctionParam to only ignore the final orig parameter

and not also drop a subst parameter.

This turned out to be more convenient for certain clients (e.g. SILGenPoly)
than requiring the full subst param list to be passed in.  These clients
want to process the subst param list separately, and dropping self early
can be convenient for that.  The only fundamental reason we need this
flag is for working with the orig type, so just use it for that; clients
that need to use this feature can reasonably be expected to cooperate.
This commit is contained in:
John McCall
2023-03-20 11:54:47 -04:00
parent 2172c0ae52
commit 2e4ad65889
3 changed files with 8 additions and 10 deletions

View File

@@ -1203,7 +1203,7 @@ unsigned AbstractionPattern::getNumFunctionParams() const {
void AbstractionPattern::
forEachFunctionParam(AnyFunctionType::CanParamArrayRef substParams,
bool ignoreFinalParam,
bool ignoreFinalOrigParam,
llvm::function_ref<void(unsigned origParamIndex,
unsigned substParamIndex,
ParameterTypeFlags origFlags,
@@ -1216,7 +1216,7 @@ forEachFunctionParam(AnyFunctionType::CanParamArrayRef substParams,
AbstractionPattern origExpansionType,
AnyFunctionType::CanParamArrayRef substParams)>
handleExpansion) const {
FunctionParamGenerator generator(*this, substParams, ignoreFinalParam);
FunctionParamGenerator generator(*this, substParams, ignoreFinalOrigParam);
for (; !generator.isFinished(); generator.advance()) {
if (generator.isPackExpansion()) {
@@ -1239,7 +1239,7 @@ forEachFunctionParam(AnyFunctionType::CanParamArrayRef substParams,
FunctionParamGenerator::FunctionParamGenerator(
AbstractionPattern origFunctionType,
AnyFunctionType::CanParamArrayRef substParams,
bool ignoreFinalParam)
bool ignoreFinalOrigParam)
: origFunctionType(origFunctionType), allSubstParams(substParams) {
origFunctionTypeIsOpaque =
(origFunctionType.isTypeParameterOrOpaqueArchetype() ||
@@ -1249,11 +1249,8 @@ FunctionParamGenerator::FunctionParamGenerator(
numOrigParams = allSubstParams.size();
} else {
numOrigParams = origFunctionType.getNumFunctionParams();
}
if (ignoreFinalParam) {
allSubstParams = allSubstParams.drop_back();
numOrigParams--;
if (ignoreFinalOrigParam)
numOrigParams--;
}
if (!isFinished()) loadParameter();