@@ -298,41 +298,48 @@ static void writeGroupNames(const comment_block::GroupNamesLayout &GroupNames,
298
298
GroupNames.emit (Scratch, BlobStream.str ());
299
299
}
300
300
301
- static bool shouldIncludeDecl (Decl *D) {
302
- if (auto *VD = dyn_cast<ValueDecl>(D)) {
303
- // Skip the decl if it's not visible to clients. The use of
304
- // getEffectiveAccess is unusual here; we want to take the testability
305
- // state into account and emit documentation if and only if they are
306
- // visible to clients (which means public ordinarily, but
307
- // public+internal when testing enabled).
308
- if (VD->getEffectiveAccess () < swift::AccessLevel::Public)
309
- return false ;
310
- }
301
+ static bool hasDoubleUnderscore (Decl *D) {
311
302
// Exclude decls with double-underscored names, either in arguments or
312
303
// base names.
313
- StringRef Prefix = " __" ;
314
- if (auto *ED = dyn_cast<ExtensionDecl>(D)) {
315
- return shouldIncludeDecl (ED->getExtendedNominal ());
316
- }
304
+ static StringRef Prefix = " __" ;
317
305
318
306
if (auto AFD = dyn_cast<AbstractFunctionDecl>(D)) {
319
307
// If it's a function with a parameter with leading double underscore,
320
308
// it's a private function.
321
309
if (AFD->getParameters ()->hasInternalParameter (Prefix))
322
- return false ;
310
+ return true ;
323
311
}
324
312
325
313
if (auto SubscriptD = dyn_cast<SubscriptDecl>(D)) {
326
314
if (SubscriptD->getIndices ()->hasInternalParameter (Prefix))
327
- return false ;
315
+ return true ;
328
316
}
329
317
if (auto *VD = dyn_cast<ValueDecl>(D)) {
330
318
auto Name = VD->getBaseName ();
331
319
if (!Name.isSpecial () &&
332
320
Name.getIdentifier ().str ().startswith (Prefix)) {
333
- return false ;
321
+ return true ;
334
322
}
335
323
}
324
+ return false ;
325
+ }
326
+
327
+ static bool shouldIncludeDecl (Decl *D, bool ExcludeDoubleUnderscore) {
328
+ if (auto *VD = dyn_cast<ValueDecl>(D)) {
329
+ // Skip the decl if it's not visible to clients. The use of
330
+ // getEffectiveAccess is unusual here; we want to take the testability
331
+ // state into account and emit documentation if and only if they are
332
+ // visible to clients (which means public ordinarily, but
333
+ // public+internal when testing enabled).
334
+ if (VD->getEffectiveAccess () < swift::AccessLevel::Public)
335
+ return false ;
336
+ }
337
+ if (auto *ED = dyn_cast<ExtensionDecl>(D)) {
338
+ return shouldIncludeDecl (ED->getExtendedNominal (), ExcludeDoubleUnderscore);
339
+ }
340
+ if (ExcludeDoubleUnderscore && hasDoubleUnderscore (D)) {
341
+ return false ;
342
+ }
336
343
return true ;
337
344
}
338
345
@@ -393,7 +400,7 @@ static void writeDeclCommentTable(
393
400
}
394
401
395
402
bool walkToDeclPre (Decl *D) override {
396
- if (!shouldIncludeDecl (D))
403
+ if (!shouldIncludeDecl (D, /* ExcludeDoubleUnderscore */ true ))
397
404
return false ;
398
405
if (!shouldSerializeDoc (D))
399
406
return true ;
@@ -789,7 +796,10 @@ struct BasicDeclLocsTableWriter : public ASTWalker {
789
796
790
797
bool walkToDeclPre (Decl *D) override {
791
798
// We shouldn't expose any Decls that .swiftdoc file isn't willing to expose.
792
- if (!shouldIncludeDecl (D))
799
+ // .swiftdoc doesn't include comments for double underscored symbols, but for .swiftsourceinfo,
800
+ // having the source location for these symbols isn't a concern becuase these
801
+ // symbols are in .swiftinterface anyway.
802
+ if (!shouldIncludeDecl (D, /* ExcludeDoubleUnderscore*/ false ))
793
803
return false ;
794
804
if (!shouldSerializeSourceLoc (D))
795
805
return true ;
0 commit comments