@@ -183,6 +183,23 @@ static bool shouldUseAllocatorMangling(const AbstractFunctionDecl *afd) {
183
183
constructor->isConvenienceInit ();
184
184
}
185
185
186
+ void TBDGenVisitor::visitDefaultArguments (ValueDecl *VD, ParameterList *PL) {
187
+ auto publicDefaultArgGenerators = SwiftModule->isTestingEnabled () ||
188
+ SwiftModule->arePrivateImportsEnabled ();
189
+ if (!publicDefaultArgGenerators)
190
+ return ;
191
+
192
+ // In Swift 3 (or under -enable-testing), default arguments (of public
193
+ // functions) are public symbols, as the default values are computed at the
194
+ // call site.
195
+ auto index = 0 ;
196
+ for (auto *param : *PL) {
197
+ if (param->isDefaultArgument ())
198
+ addSymbol (SILDeclRef::getDefaultArgGenerator (VD, index));
199
+ index++;
200
+ }
201
+ }
202
+
186
203
void TBDGenVisitor::visitAbstractFunctionDecl (AbstractFunctionDecl *AFD) {
187
204
// A @_silgen_name("...") function without a body only exists
188
205
// to forward-declare a symbol from another library.
@@ -199,7 +216,6 @@ void TBDGenVisitor::visitAbstractFunctionDecl(AbstractFunctionDecl *AFD) {
199
216
AFD, useAllocator));
200
217
addSymbol (
201
218
LinkEntity::forDynamicallyReplaceableFunctionKey (AFD, useAllocator));
202
-
203
219
}
204
220
if (AFD->getAttrs ().hasAttribute <DynamicReplacementAttr>()) {
205
221
bool useAllocator = shouldUseAllocatorMangling (AFD);
@@ -215,20 +231,7 @@ void TBDGenVisitor::visitAbstractFunctionDecl(AbstractFunctionDecl *AFD) {
215
231
addSymbol (SILDeclRef (AFD).asForeign ());
216
232
}
217
233
218
- auto publicDefaultArgGenerators = SwiftModule->isTestingEnabled () ||
219
- SwiftModule->arePrivateImportsEnabled ();
220
- if (!publicDefaultArgGenerators)
221
- return ;
222
-
223
- // In Swift 3 (or under -enable-testing), default arguments (of public
224
- // functions) are public symbols, as the default values are computed at the
225
- // call site.
226
- auto index = 0 ;
227
- for (auto *param : *AFD->getParameters ()) {
228
- if (param->isDefaultArgument ())
229
- addSymbol (SILDeclRef::getDefaultArgGenerator (AFD, index));
230
- index++;
231
- }
234
+ visitDefaultArguments (AFD, AFD->getParameters ());
232
235
}
233
236
234
237
void TBDGenVisitor::visitFuncDecl (FuncDecl *FD) {
@@ -559,12 +562,12 @@ void TBDGenVisitor::visitEnumDecl(EnumDecl *ED) {
559
562
560
563
if (!ED->isResilient ())
561
564
return ;
565
+ }
562
566
563
- // Emit resilient tags.
564
- for (auto *elt : ED->getAllElements ()) {
565
- auto entity = LinkEntity::forEnumCase (elt);
566
- addSymbol (entity);
567
- }
567
+ void TBDGenVisitor::visitEnumElementDecl (EnumElementDecl *EED) {
568
+ addSymbol (LinkEntity::forEnumCase (EED));
569
+ if (auto *PL = EED->getParameterList ())
570
+ visitDefaultArguments (EED, PL);
568
571
}
569
572
570
573
void TBDGenVisitor::addFirstFileSymbols () {
0 commit comments