Skip to content

Commit adceb7a

Browse files
committed
Serialize/deserialize lifetime dependencies on enum elements
1 parent 7a6078c commit adceb7a

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
@@ -5259,6 +5259,16 @@ class DeclDeserializer {
52595259
elem->setAccess(std::max(cast<EnumDecl>(DC)->getFormalAccess(),
52605260
AccessLevel::Internal));
52615261

5262+
SmallVector<LifetimeDependenceInfo, 1> lifetimeDependencies;
5263+
while (auto info = MF.maybeReadLifetimeDependence()) {
5264+
assert(info.has_value());
5265+
lifetimeDependencies.push_back(*info);
5266+
}
5267+
5268+
ctx.evaluator.cacheOutput(LifetimeDependenceInfoRequest{elem},
5269+
lifetimeDependencies.empty()? std::nullopt :
5270+
ctx.AllocateCopy(lifetimeDependencies));
5271+
52625272
return elem;
52635273
}
52645274

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 = 954; // Checked cast inst options
61+
const uint16_t SWIFTMODULE_VERSION_MINOR = 955; // 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
@@ -5021,6 +5021,14 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
50215021
nameComponentsAndDependencies);
50225022
if (auto *PL = elem->getParameterList())
50235023
writeParameterList(PL);
5024+
5025+
auto fnType = ty->getAs<AnyFunctionType>();
5026+
if (fnType) {
5027+
auto lifetimeDependencies = fnType->getLifetimeDependencies();
5028+
if (!lifetimeDependencies.empty()) {
5029+
S.writeLifetimeDependencies(lifetimeDependencies);
5030+
}
5031+
}
50245032
}
50255033

50265034
void visitSubscriptDecl(const SubscriptDecl *subscript) {

0 commit comments

Comments
 (0)