mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Serialization: Option to skip writing decls marked @_implementationOnly
This commit is contained in:
@@ -163,6 +163,7 @@ public:
|
||||
bool HermeticSealAtLink = false;
|
||||
bool EmbeddedSwiftModule = false;
|
||||
bool SkipNonExportableDecls = false;
|
||||
bool SkipImplementationOnlyDecls = false;
|
||||
bool ExplicitModuleBuild = false;
|
||||
bool EnableSerializationRemarks = false;
|
||||
bool IsInterfaceSDKRelative = false;
|
||||
|
||||
@@ -284,6 +284,9 @@ SerializationOptions CompilerInvocation::computeSerializationOptions(
|
||||
serializationOpts.SkipNonExportableDecls =
|
||||
getLangOptions().SkipNonExportableDecls;
|
||||
|
||||
serializationOpts.SkipImplementationOnlyDecls =
|
||||
getLangOptions().hasFeature(Feature::CheckImplementationOnly);
|
||||
|
||||
serializationOpts.ExplicitModuleBuild = FrontendOpts.DisableImplicitModules;
|
||||
|
||||
serializationOpts.EnableSerializationRemarks =
|
||||
|
||||
@@ -5390,6 +5390,20 @@ bool Serializer::shouldSkipDecl(const Decl *D) const {
|
||||
void Serializer::writeASTBlockEntity(const Decl *D) {
|
||||
using namespace decls_block;
|
||||
|
||||
if (Options.SkipImplementationOnlyDecls) {
|
||||
// Skip @_implementationOnly types.
|
||||
if (D->getAttrs().hasAttribute<ImplementationOnlyAttr>())
|
||||
return;
|
||||
|
||||
// Skip non-public @export(interface) functions.
|
||||
auto FD = dyn_cast<AbstractFunctionDecl>(D);
|
||||
if (FD &&
|
||||
FD->getAttrs().hasAttribute<NeverEmitIntoClientAttr>() &&
|
||||
!FD->getFormalAccessScope(/*useDC*/nullptr,
|
||||
/*treatUsableFromInlineAsPublic*/true).isPublicOrPackage())
|
||||
return;
|
||||
}
|
||||
|
||||
PrettyStackTraceDecl trace("serializing", D);
|
||||
assert(DeclsToSerialize.hasRef(D));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user