mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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:
@@ -81,7 +81,7 @@ class FunctionParamGenerator {
|
|||||||
public:
|
public:
|
||||||
FunctionParamGenerator(AbstractionPattern origFunctionType,
|
FunctionParamGenerator(AbstractionPattern origFunctionType,
|
||||||
AnyFunctionType::CanParamArrayRef substParams,
|
AnyFunctionType::CanParamArrayRef substParams,
|
||||||
bool ignoreFinalParam);
|
bool ignoreFinalOrigParam);
|
||||||
|
|
||||||
/// Is the traversal finished? If so, none of the getters below
|
/// Is the traversal finished? If so, none of the getters below
|
||||||
/// are allowed to be called.
|
/// are allowed to be called.
|
||||||
|
|||||||
@@ -1203,7 +1203,7 @@ unsigned AbstractionPattern::getNumFunctionParams() const {
|
|||||||
|
|
||||||
void AbstractionPattern::
|
void AbstractionPattern::
|
||||||
forEachFunctionParam(AnyFunctionType::CanParamArrayRef substParams,
|
forEachFunctionParam(AnyFunctionType::CanParamArrayRef substParams,
|
||||||
bool ignoreFinalParam,
|
bool ignoreFinalOrigParam,
|
||||||
llvm::function_ref<void(unsigned origParamIndex,
|
llvm::function_ref<void(unsigned origParamIndex,
|
||||||
unsigned substParamIndex,
|
unsigned substParamIndex,
|
||||||
ParameterTypeFlags origFlags,
|
ParameterTypeFlags origFlags,
|
||||||
@@ -1216,7 +1216,7 @@ forEachFunctionParam(AnyFunctionType::CanParamArrayRef substParams,
|
|||||||
AbstractionPattern origExpansionType,
|
AbstractionPattern origExpansionType,
|
||||||
AnyFunctionType::CanParamArrayRef substParams)>
|
AnyFunctionType::CanParamArrayRef substParams)>
|
||||||
handleExpansion) const {
|
handleExpansion) const {
|
||||||
FunctionParamGenerator generator(*this, substParams, ignoreFinalParam);
|
FunctionParamGenerator generator(*this, substParams, ignoreFinalOrigParam);
|
||||||
|
|
||||||
for (; !generator.isFinished(); generator.advance()) {
|
for (; !generator.isFinished(); generator.advance()) {
|
||||||
if (generator.isPackExpansion()) {
|
if (generator.isPackExpansion()) {
|
||||||
@@ -1239,7 +1239,7 @@ forEachFunctionParam(AnyFunctionType::CanParamArrayRef substParams,
|
|||||||
FunctionParamGenerator::FunctionParamGenerator(
|
FunctionParamGenerator::FunctionParamGenerator(
|
||||||
AbstractionPattern origFunctionType,
|
AbstractionPattern origFunctionType,
|
||||||
AnyFunctionType::CanParamArrayRef substParams,
|
AnyFunctionType::CanParamArrayRef substParams,
|
||||||
bool ignoreFinalParam)
|
bool ignoreFinalOrigParam)
|
||||||
: origFunctionType(origFunctionType), allSubstParams(substParams) {
|
: origFunctionType(origFunctionType), allSubstParams(substParams) {
|
||||||
origFunctionTypeIsOpaque =
|
origFunctionTypeIsOpaque =
|
||||||
(origFunctionType.isTypeParameterOrOpaqueArchetype() ||
|
(origFunctionType.isTypeParameterOrOpaqueArchetype() ||
|
||||||
@@ -1249,11 +1249,8 @@ FunctionParamGenerator::FunctionParamGenerator(
|
|||||||
numOrigParams = allSubstParams.size();
|
numOrigParams = allSubstParams.size();
|
||||||
} else {
|
} else {
|
||||||
numOrigParams = origFunctionType.getNumFunctionParams();
|
numOrigParams = origFunctionType.getNumFunctionParams();
|
||||||
}
|
if (ignoreFinalOrigParam)
|
||||||
|
numOrigParams--;
|
||||||
if (ignoreFinalParam) {
|
|
||||||
allSubstParams = allSubstParams.drop_back();
|
|
||||||
numOrigParams--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isFinished()) loadParameter();
|
if (!isFinished()) loadParameter();
|
||||||
|
|||||||
@@ -1569,7 +1569,8 @@ private:
|
|||||||
maybeAddForeignParameters();
|
maybeAddForeignParameters();
|
||||||
|
|
||||||
// Process all the non-self parameters.
|
// Process all the non-self parameters.
|
||||||
origType.forEachFunctionParam(params, hasSelf,
|
origType.forEachFunctionParam(params.drop_back(hasSelf ? 1 : 0),
|
||||||
|
/*ignore final orig param*/ hasSelf,
|
||||||
[&](unsigned origParamIndex, unsigned substParamIndex,
|
[&](unsigned origParamIndex, unsigned substParamIndex,
|
||||||
ParameterTypeFlags origFlags,
|
ParameterTypeFlags origFlags,
|
||||||
AbstractionPattern origParamType,
|
AbstractionPattern origParamType,
|
||||||
|
|||||||
Reference in New Issue
Block a user