mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[SE-0155] Default Arguments in Enum Cases
The bulk of the changes are to SILGenApply. As we must now evaluate the payload ArgumentSource to an RValue, we follow the example of subscripts and lie to the argument emitter. This evaluates arguments at +1 which can lead to slightly worse codegen at -Onone.
This commit is contained in:
@@ -467,8 +467,14 @@ IsSerialized_t SILDeclRef::isSerialized() const {
|
||||
// Default argument generators are serialized if the function was
|
||||
// type-checked in Swift 4 mode.
|
||||
if (isDefaultArgGenerator()) {
|
||||
auto *afd = cast<AbstractFunctionDecl>(d);
|
||||
switch (afd->getDefaultArgumentResilienceExpansion()) {
|
||||
ResilienceExpansion expansion;
|
||||
if (auto *EED = dyn_cast<EnumElementDecl>(d)) {
|
||||
expansion = EED->getDefaultArgumentResilienceExpansion();
|
||||
} else {
|
||||
expansion = cast<AbstractFunctionDecl>(d)
|
||||
->getDefaultArgumentResilienceExpansion();
|
||||
}
|
||||
switch (expansion) {
|
||||
case ResilienceExpansion::Minimal:
|
||||
return IsSerialized;
|
||||
case ResilienceExpansion::Maximal:
|
||||
@@ -770,7 +776,7 @@ std::string SILDeclRef::mangle(ManglingKind MKind) const {
|
||||
case SILDeclRef::Kind::DefaultArgGenerator:
|
||||
assert(!isCurried);
|
||||
return mangler.mangleDefaultArgumentEntity(
|
||||
cast<AbstractFunctionDecl>(getDecl()),
|
||||
cast<DeclContext>(getDecl()),
|
||||
defaultArgIndex,
|
||||
SKind);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user