@@ -2400,6 +2400,12 @@ static CanSILFunctionType getNativeSILFunctionType(
2400
2400
Optional<SubstitutionMap> reqtSubs,
2401
2401
ProtocolConformanceRef witnessMethodConformance) {
2402
2402
assert (bool (origConstant) == bool (constant));
2403
+ auto getSILFunctionTypeForConventions =
2404
+ [&](const Conventions &convs) -> CanSILFunctionType {
2405
+ return getSILFunctionType (TC, context, origType, substInterfaceType,
2406
+ extInfo, convs, ForeignInfo (), origConstant,
2407
+ constant, reqtSubs, witnessMethodConformance);
2408
+ };
2403
2409
switch (extInfo.getSILRepresentation ()) {
2404
2410
case SILFunctionType::Representation::Block:
2405
2411
case SILFunctionType::Representation::CFunctionPointer:
@@ -2416,42 +2422,29 @@ static CanSILFunctionType getNativeSILFunctionType(
2416
2422
switch (constant ? constant->kind : SILDeclRef::Kind::Func) {
2417
2423
case SILDeclRef::Kind::Initializer:
2418
2424
case SILDeclRef::Kind::EnumElement:
2419
- return getSILFunctionType (TC, context, origType, substInterfaceType,
2420
- extInfo, DefaultInitializerConventions (),
2421
- ForeignInfo (), origConstant, constant, reqtSubs,
2422
- witnessMethodConformance);
2425
+ return getSILFunctionTypeForConventions (DefaultInitializerConventions ());
2423
2426
case SILDeclRef::Kind::Allocator:
2424
- return getSILFunctionType (TC, context, origType, substInterfaceType,
2425
- extInfo, DefaultAllocatorConventions (),
2426
- ForeignInfo (), origConstant, constant, reqtSubs,
2427
- witnessMethodConformance);
2428
- case SILDeclRef::Kind::Func:
2427
+ return getSILFunctionTypeForConventions (DefaultAllocatorConventions ());
2428
+ case SILDeclRef::Kind::Func: {
2429
2429
// If we have a setter, use the special setter convention. This ensures
2430
2430
// that we take normal parameters at +1.
2431
2431
if (constant && constant->isSetter ()) {
2432
- return getSILFunctionType (TC, context, origType, substInterfaceType,
2433
- extInfo, DefaultSetterConventions (),
2434
- ForeignInfo (), origConstant, constant,
2435
- reqtSubs, witnessMethodConformance);
2432
+ return getSILFunctionTypeForConventions (DefaultSetterConventions ());
2436
2433
}
2437
- LLVM_FALLTHROUGH;
2434
+ return getSILFunctionTypeForConventions (
2435
+ DefaultConventions (NormalParameterConvention::Guaranteed));
2436
+ }
2438
2437
case SILDeclRef::Kind::Destroyer:
2439
2438
case SILDeclRef::Kind::GlobalAccessor:
2440
2439
case SILDeclRef::Kind::DefaultArgGenerator:
2441
2440
case SILDeclRef::Kind::StoredPropertyInitializer:
2442
2441
case SILDeclRef::Kind::PropertyWrapperBackingInitializer:
2443
2442
case SILDeclRef::Kind::IVarInitializer:
2444
- case SILDeclRef::Kind::IVarDestroyer: {
2445
- auto conv = DefaultConventions (NormalParameterConvention::Guaranteed);
2446
- return getSILFunctionType (TC, context, origType, substInterfaceType,
2447
- extInfo, conv, ForeignInfo (), origConstant,
2448
- constant, reqtSubs, witnessMethodConformance);
2449
- }
2443
+ case SILDeclRef::Kind::IVarDestroyer:
2444
+ return getSILFunctionTypeForConventions (
2445
+ DefaultConventions (NormalParameterConvention::Guaranteed));
2450
2446
case SILDeclRef::Kind::Deallocator:
2451
- return getSILFunctionType (TC, context, origType, substInterfaceType,
2452
- extInfo, DeallocatorConventions (),
2453
- ForeignInfo (), origConstant, constant, reqtSubs,
2454
- witnessMethodConformance);
2447
+ return getSILFunctionTypeForConventions (DeallocatorConventions ());
2455
2448
}
2456
2449
}
2457
2450
}
0 commit comments