Skip to content

Commit d430d12

Browse files
committed
SIL: Don't destructure tuples in AbstractionPattern::getErrorConvention()
Tuples don't conform to Error anyway so it's moot, but if they ever do we won't be destructuring them into multiple indirect error results.
1 parent e081154 commit d430d12

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

lib/SIL/IR/AbstractionPattern.cpp

+10-17
Original file line numberDiff line numberDiff line change
@@ -2044,15 +2044,21 @@ AbstractionPattern::getParameterConvention(TypeConverter &TC) const {
20442044

20452045
AbstractionPattern::CallingConventionKind
20462046
AbstractionPattern::getErrorConvention(TypeConverter &TC) const {
2047-
// Tuples should be destructured.
2048-
if (isTuple()) {
2049-
return Destructured;
2050-
}
20512047
switch (getKind()) {
20522048
case Kind::Opaque:
20532049
// Maximally abstracted values are always thrown indirectly.
20542050
return Indirect;
20552051

2052+
case Kind::ClangType:
2053+
case Kind::Type:
2054+
case Kind::Discard:
2055+
// Pass according to the formal type.
2056+
return SILType::isFormallyThrownIndirectly(getType(),
2057+
TC,
2058+
getGenericSignatureOrNull())
2059+
? Indirect : Direct;
2060+
2061+
case Kind::Tuple:
20562062
case Kind::OpaqueFunction:
20572063
case Kind::OpaqueDerivativeFunction:
20582064
case Kind::PartialCurriedObjCMethodType:
@@ -2064,20 +2070,7 @@ AbstractionPattern::getErrorConvention(TypeConverter &TC) const {
20642070
case Kind::CXXMethodType:
20652071
case Kind::CurriedCXXMethodType:
20662072
case Kind::PartialCurriedCXXMethodType:
2067-
// Function types are always thrown directly
2068-
return Direct;
2069-
2070-
case Kind::ClangType:
2071-
case Kind::Type:
2072-
case Kind::Discard:
2073-
// Pass according to the formal type.
2074-
return SILType::isFormallyThrownIndirectly(getType(),
2075-
TC,
2076-
getGenericSignatureOrNull())
2077-
? Indirect : Direct;
2078-
20792073
case Kind::Invalid:
2080-
case Kind::Tuple:
20812074
case Kind::ObjCCompletionHandlerArgumentsType:
20822075
llvm_unreachable("should not get here");
20832076
}

0 commit comments

Comments
 (0)