mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #71567 from gottesmm/transferring-param
[transferring] Implement transferring result and clean up transferring param support by making transferring a bit on param instead of a ParamSpecifier.
This commit is contained in:
@@ -2885,7 +2885,7 @@ getActualParamDeclSpecifier(serialization::ParamDeclSpecifier raw) {
|
||||
CASE(Consuming)
|
||||
CASE(LegacyShared)
|
||||
CASE(LegacyOwned)
|
||||
CASE(Transferring)
|
||||
CASE(ImplicitlyCopyableConsuming)
|
||||
}
|
||||
#undef CASE
|
||||
return llvm::None;
|
||||
@@ -3813,6 +3813,7 @@ public:
|
||||
bool isAutoClosure;
|
||||
bool isIsolated;
|
||||
bool isCompileTimeConst;
|
||||
bool isTransferring;
|
||||
uint8_t rawDefaultArg;
|
||||
TypeID defaultExprType;
|
||||
uint8_t rawDefaultArgIsolation;
|
||||
@@ -3823,6 +3824,7 @@ public:
|
||||
interfaceTypeID, isIUO, isVariadic,
|
||||
isAutoClosure, isIsolated,
|
||||
isCompileTimeConst,
|
||||
isTransferring,
|
||||
rawDefaultArg,
|
||||
defaultExprType,
|
||||
rawDefaultArgIsolation,
|
||||
@@ -3862,6 +3864,7 @@ public:
|
||||
param->setAutoClosure(isAutoClosure);
|
||||
param->setIsolated(isIsolated);
|
||||
param->setCompileTimeConst(isCompileTimeConst);
|
||||
param->setTransferring(isTransferring);
|
||||
|
||||
// Decode the default argument kind.
|
||||
// FIXME: Default argument expression, if available.
|
||||
@@ -3926,6 +3929,7 @@ public:
|
||||
DeclID opaqueReturnTypeID;
|
||||
bool isUserAccessible;
|
||||
bool isDistributedThunk;
|
||||
bool hasTransferringResult = false;
|
||||
ArrayRef<uint64_t> nameAndDependencyIDs;
|
||||
|
||||
if (!isAccessor) {
|
||||
@@ -3945,6 +3949,7 @@ public:
|
||||
opaqueReturnTypeID,
|
||||
isUserAccessible,
|
||||
isDistributedThunk,
|
||||
hasTransferringResult,
|
||||
nameAndDependencyIDs);
|
||||
} else {
|
||||
decls_block::AccessorLayout::readRecord(scratch, contextID, isImplicit,
|
||||
@@ -4161,6 +4166,9 @@ public:
|
||||
|
||||
fn->setDistributedThunk(isDistributedThunk);
|
||||
|
||||
if (hasTransferringResult)
|
||||
fn->setTransferringResult();
|
||||
|
||||
return fn;
|
||||
}
|
||||
|
||||
@@ -6425,6 +6433,11 @@ getActualSILParameterOptions(uint8_t raw) {
|
||||
result |= SILParameterInfo::Isolated;
|
||||
}
|
||||
|
||||
if (options.contains(serialization::SILParameterInfoFlags::Transferring)) {
|
||||
options -= serialization::SILParameterInfoFlags::Transferring;
|
||||
result |= SILParameterInfo::Transferring;
|
||||
}
|
||||
|
||||
// Check if we have any remaining options and return none if we do. We found
|
||||
// some option that we did not understand.
|
||||
if (bool(options)) {
|
||||
@@ -6698,7 +6711,7 @@ detail::function_deserializer::deserialize(ModuleFile &MF,
|
||||
StringRef blobData, bool isGeneric) {
|
||||
TypeID resultID;
|
||||
uint8_t rawRepresentation, rawDiffKind;
|
||||
bool noescape = false, concurrent, async, throws;
|
||||
bool noescape = false, concurrent, async, throws, hasTransferringResult;
|
||||
TypeID thrownErrorID;
|
||||
GenericSignature genericSig;
|
||||
TypeID clangTypeID;
|
||||
@@ -6707,12 +6720,14 @@ detail::function_deserializer::deserialize(ModuleFile &MF,
|
||||
if (!isGeneric) {
|
||||
decls_block::FunctionTypeLayout::readRecord(
|
||||
scratch, resultID, rawRepresentation, clangTypeID, noescape, concurrent,
|
||||
async, throws, thrownErrorID, rawDiffKind, rawIsolation);
|
||||
async, throws, thrownErrorID, rawDiffKind, rawIsolation,
|
||||
hasTransferringResult);
|
||||
} else {
|
||||
GenericSignatureID rawGenericSig;
|
||||
decls_block::GenericFunctionTypeLayout::readRecord(
|
||||
scratch, resultID, rawRepresentation, concurrent, async, throws,
|
||||
thrownErrorID, rawDiffKind, rawIsolation, rawGenericSig);
|
||||
thrownErrorID, rawDiffKind, rawIsolation, hasTransferringResult,
|
||||
rawGenericSig);
|
||||
genericSig = MF.getGenericSignature(rawGenericSig);
|
||||
clangTypeID = 0;
|
||||
}
|
||||
@@ -6762,7 +6777,8 @@ detail::function_deserializer::deserialize(ModuleFile &MF,
|
||||
// TODO: Handle LifetimeDependenceInfo here.
|
||||
auto info = FunctionType::ExtInfoBuilder(
|
||||
*representation, noescape, throws, thrownError, *diffKind,
|
||||
clangFunctionType, isolation, LifetimeDependenceInfo())
|
||||
clangFunctionType, isolation, LifetimeDependenceInfo(),
|
||||
hasTransferringResult)
|
||||
.withConcurrent(concurrent)
|
||||
.withAsync(async)
|
||||
.build();
|
||||
@@ -7252,6 +7268,7 @@ Expected<Type> DESERIALIZE_TYPE(SIL_FUNCTION_TYPE)(
|
||||
bool noescape;
|
||||
bool erasedIsolation;
|
||||
bool hasErrorResult;
|
||||
bool hasTransferringResult;
|
||||
unsigned numParams;
|
||||
unsigned numYields;
|
||||
unsigned numResults;
|
||||
@@ -7264,7 +7281,7 @@ Expected<Type> DESERIALIZE_TYPE(SIL_FUNCTION_TYPE)(
|
||||
decls_block::SILFunctionTypeLayout::readRecord(
|
||||
scratch, concurrent, async, rawCoroutineKind, rawCalleeConvention,
|
||||
rawRepresentation, pseudogeneric, noescape, unimplementable,
|
||||
erasedIsolation, rawDiffKind, hasErrorResult,
|
||||
erasedIsolation, rawDiffKind, hasErrorResult, hasTransferringResult,
|
||||
numParams, numYields, numResults, rawInvocationGenericSig,
|
||||
rawInvocationSubs, rawPatternSubs, clangFunctionTypeID, variableData);
|
||||
|
||||
@@ -7291,11 +7308,12 @@ Expected<Type> DESERIALIZE_TYPE(SIL_FUNCTION_TYPE)(
|
||||
isolation = SILFunctionTypeIsolation::Erased;
|
||||
|
||||
// Handle LifetimeDependenceInfo here.
|
||||
auto extInfo = SILFunctionType::ExtInfoBuilder(
|
||||
*representation, pseudogeneric, noescape, concurrent,
|
||||
async, unimplementable, isolation, *diffKind,
|
||||
clangFunctionType, LifetimeDependenceInfo())
|
||||
.build();
|
||||
auto extInfo =
|
||||
SILFunctionType::ExtInfoBuilder(
|
||||
*representation, pseudogeneric, noescape, concurrent, async,
|
||||
unimplementable, isolation, *diffKind, clangFunctionType,
|
||||
LifetimeDependenceInfo(), hasTransferringResult)
|
||||
.build();
|
||||
|
||||
// Process the coroutine kind.
|
||||
auto coroutineKind = getActualSILCoroutineKind(rawCoroutineKind);
|
||||
|
||||
Reference in New Issue
Block a user