Skip to content

Commit 3032dbd

Browse files
committed
[Serialization] Implement serialization/deserialization for the typeEraser
attribute.
1 parent 96d7434 commit 3032dbd

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

include/swift/AST/Attr.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ SIMPLE_DECL_ATTR(_inheritsConvenienceInitializers,
520520
93)
521521

522522
DECL_ATTR(_typeEraser, TypeEraser,
523-
OnProtocol | UserInaccessible | NotSerialized |
523+
OnProtocol | UserInaccessible |
524524
ABIStableToAdd | ABIBreakingToRemove | APIStableToAdd | APIBreakingToRemove,
525525
94)
526526

lib/Serialization/Deserialization.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4208,6 +4208,19 @@ llvm::Error DeclDeserializer::deserializeDeclAttributes() {
42084208
break;
42094209
}
42104210

4211+
case decls_block::TypeEraser_DECL_ATTR: {
4212+
bool isImplicit;
4213+
TypeID typeEraserID;
4214+
serialization::decls_block::TypeEraserDeclAttrLayout::readRecord(
4215+
scratch, isImplicit, typeEraserID);
4216+
4217+
auto typeEraser = MF.getType(typeEraserID);
4218+
assert(!isImplicit);
4219+
Attr = new (ctx) TypeEraserAttr(SourceLoc(), SourceRange(),
4220+
TypeLoc::withoutLoc(typeEraser));
4221+
break;
4222+
}
4223+
42114224
case decls_block::Custom_DECL_ATTR: {
42124225
bool isImplicit;
42134226
TypeID typeID;

lib/Serialization/Serialization.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2173,7 +2173,6 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
21732173
case DAK_RestatedObjCConformance:
21742174
case DAK_ClangImporterSynthesizedType:
21752175
case DAK_PrivateImport:
2176-
case DAK_TypeEraser:
21772176
llvm_unreachable("cannot serialize attribute");
21782177

21792178
case DAK_Count:
@@ -2364,6 +2363,16 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
23642363
return;
23652364
}
23662365

2366+
case DAK_TypeEraser: {
2367+
auto abbrCode = S.DeclTypeAbbrCodes[TypeEraserDeclAttrLayout::Code];
2368+
auto attr = cast<TypeEraserAttr>(DA);
2369+
auto typeEraser = attr->getTypeEraserLoc().getType();
2370+
TypeEraserDeclAttrLayout::emitRecord(S.Out, S.ScratchRecord, abbrCode,
2371+
attr->isImplicit(),
2372+
S.addTypeRef(typeEraser));
2373+
return;
2374+
}
2375+
23672376
case DAK_Custom: {
23682377
auto abbrCode = S.DeclTypeAbbrCodes[CustomDeclAttrLayout::Code];
23692378
auto theAttr = cast<CustomAttr>(DA);

0 commit comments

Comments
 (0)