File tree Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -4099,6 +4099,10 @@ class AbstractStorageDecl : public ValueDecl {
4099
4099
4100
4100
FuncDecl *getAccessorFunction (AccessorKind accessor) const ;
4101
4101
4102
+ // / \brief Push all of the accessor functions associated with this VarDecl
4103
+ // / onto `decls`.
4104
+ void getAllAccessorFunctions (SmallVectorImpl<Decl *> &decls) const ;
4105
+
4102
4106
// / \brief Turn this into a computed variable, providing a getter and setter.
4103
4107
void makeComputed (SourceLoc LBraceLoc, FuncDecl *Get, FuncDecl *Set,
4104
4108
FuncDecl *MaterializeForSet, SourceLoc RBraceLoc);
Original file line number Diff line number Diff line change @@ -3430,6 +3430,28 @@ FuncDecl *AbstractStorageDecl::getAccessorFunction(AccessorKind kind) const {
3430
3430
llvm_unreachable (" bad accessor kind!" );
3431
3431
}
3432
3432
3433
+ void AbstractStorageDecl::getAllAccessorFunctions (
3434
+ SmallVectorImpl<Decl *> &decls) const {
3435
+ auto tryPush = [&](Decl *decl) {
3436
+ if (decl)
3437
+ decls.push_back (decl);
3438
+ };
3439
+
3440
+ tryPush (getGetter ());
3441
+ tryPush (getSetter ());
3442
+ tryPush (getMaterializeForSetFunc ());
3443
+
3444
+ if (hasObservers ()) {
3445
+ tryPush (getDidSetFunc ());
3446
+ tryPush (getWillSetFunc ());
3447
+ }
3448
+
3449
+ if (hasAddressors ()) {
3450
+ tryPush (getAddressor ());
3451
+ tryPush (getMutableAddressor ());
3452
+ }
3453
+ }
3454
+
3433
3455
void AbstractStorageDecl::configureGetSetRecord (GetSetRecord *getSetInfo,
3434
3456
FuncDecl *getter,
3435
3457
FuncDecl *setter,
Original file line number Diff line number Diff line change @@ -96,6 +96,8 @@ class TBDGenVisitor : public ASTVisitor<TBDGenVisitor> {
96
96
addMembers (ED->getMembers ());
97
97
else if (auto NTD = dyn_cast<NominalTypeDecl>(D))
98
98
addMembers (NTD->getMembers ());
99
+ else if (auto VD = dyn_cast<VarDecl>(D))
100
+ VD->getAllAccessorFunctions (members);
99
101
100
102
for (auto member : members) {
101
103
ASTVisitor::visit (member);
@@ -221,9 +223,11 @@ void TBDGenVisitor::visitVarDecl(VarDecl *VD) {
221
223
// like globals.
222
224
if (!FileHasEntryPoint)
223
225
addSymbol (SILDeclRef (VD, SILDeclRef::Kind::GlobalAccessor));
224
- }
225
226
226
- visitMembers (VD);
227
+ // In this case, the members of the VarDecl don't also appear as top-level
228
+ // decls, so we need to explicitly walk them.
229
+ visitMembers (VD);
230
+ }
227
231
}
228
232
229
233
void TBDGenVisitor::visitNominalTypeDecl (NominalTypeDecl *NTD) {
You can’t perform that action at this time.
0 commit comments