Skip to content

Commit e07f047

Browse files
authored
Merge pull request #15795 from aschwaighofer/tbd_resilient_enum
2 parents e5d913b + c17829c commit e07f047

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

lib/TBDGen/TBDGen.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,17 @@ void TBDGenVisitor::visitProtocolDecl(ProtocolDecl *PD) {
299299
#endif
300300
}
301301

302+
void TBDGenVisitor::visitEnumDecl(EnumDecl *ED) {
303+
if (!ED->isResilient(SwiftModule, ResilienceExpansion::Minimal))
304+
return;
305+
306+
// Emit resilient tags.
307+
for (auto *elt : ED->getAllElements()) {
308+
auto entity = LinkEntity::forEnumCase(elt);
309+
addSymbol(entity);
310+
}
311+
}
312+
302313
static void enumeratePublicSymbolsAndWrite(ModuleDecl *M, FileUnit *singleFile,
303314
StringSet &symbols,
304315
bool hasMultipleIGMs,

lib/TBDGen/TBDGenVisitor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ class TBDGenVisitor : public ASTVisitor<TBDGenVisitor> {
100100

101101
void visitVarDecl(VarDecl *VD);
102102

103+
void visitEnumDecl(EnumDecl *ED);
104+
103105
void visitDecl(Decl *D) {}
104106
};
105107
} // end namespace tbdgen

test/TBD/enum.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %target-swift-frontend -emit-ir -o- -parse-as-library -module-name test -validate-tbd-against-ir=missing %s
2+
// RUN: %target-swift-frontend -enable-resilience -emit-ir -o- -parse-as-library -module-name test -validate-tbd-against-ir=missing %s
3+
4+
class C {
5+
}
6+
7+
enum SinglePayload {
8+
case A
9+
case B(C)
10+
case D
11+
}
12+
13+
enum MultiPayload {
14+
case A
15+
case B(C)
16+
case D(C)
17+
}

0 commit comments

Comments
 (0)