Skip to content

Commit 9604081

Browse files
committed
Serialize/deserialize lifetime dependencies on enum elements
1 parent 45af6d6 commit 9604081

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

lib/Serialization/Deserialization.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5213,6 +5213,16 @@ class DeclDeserializer {
52135213
elem->setAccess(std::max(cast<EnumDecl>(DC)->getFormalAccess(),
52145214
AccessLevel::Internal));
52155215

5216+
SmallVector<LifetimeDependenceInfo, 1> lifetimeDependencies;
5217+
while (auto info = MF.maybeReadLifetimeDependence()) {
5218+
assert(info.has_value());
5219+
lifetimeDependencies.push_back(*info);
5220+
}
5221+
5222+
ctx.evaluator.cacheOutput(LifetimeDependenceInfoRequest{elem},
5223+
lifetimeDependencies.empty()? std::nullopt :
5224+
ctx.AllocateCopy(lifetimeDependencies));
5225+
52165226
return elem;
52175227
}
52185228

lib/Serialization/ModuleFormat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
5858
/// describe what change you made. The content of this comment isn't important;
5959
/// it just ensures a conflict if two people change the module format.
6060
/// Don't worry about adhering to the 80-column limit for this line.
61-
const uint16_t SWIFTMODULE_VERSION_MINOR = 942; // update LifetimeDependenceLayout
61+
const uint16_t SWIFTMODULE_VERSION_MINOR = 943; // Lifetime dependencies on enum element
6262

6363
/// A standard hash seed used for all string hashes in a serialized module.
6464
///

lib/Serialization/Serialization.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5014,6 +5014,14 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
50145014
nameComponentsAndDependencies);
50155015
if (auto *PL = elem->getParameterList())
50165016
writeParameterList(PL);
5017+
5018+
auto fnType = ty->getAs<AnyFunctionType>();
5019+
if (fnType) {
5020+
auto lifetimeDependencies = fnType->getLifetimeDependencies();
5021+
if (!lifetimeDependencies.empty()) {
5022+
S.writeLifetimeDependencies(lifetimeDependencies);
5023+
}
5024+
}
50175025
}
50185026

50195027
void visitSubscriptDecl(const SubscriptDecl *subscript) {

0 commit comments

Comments
 (0)