mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Serialization: Option to skip writing decls marked @_implementationOnly
This commit is contained in:
@@ -163,6 +163,7 @@ public:
|
|||||||
bool HermeticSealAtLink = false;
|
bool HermeticSealAtLink = false;
|
||||||
bool EmbeddedSwiftModule = false;
|
bool EmbeddedSwiftModule = false;
|
||||||
bool SkipNonExportableDecls = false;
|
bool SkipNonExportableDecls = false;
|
||||||
|
bool SkipImplementationOnlyDecls = false;
|
||||||
bool ExplicitModuleBuild = false;
|
bool ExplicitModuleBuild = false;
|
||||||
bool EnableSerializationRemarks = false;
|
bool EnableSerializationRemarks = false;
|
||||||
bool IsInterfaceSDKRelative = false;
|
bool IsInterfaceSDKRelative = false;
|
||||||
|
|||||||
@@ -284,6 +284,9 @@ SerializationOptions CompilerInvocation::computeSerializationOptions(
|
|||||||
serializationOpts.SkipNonExportableDecls =
|
serializationOpts.SkipNonExportableDecls =
|
||||||
getLangOptions().SkipNonExportableDecls;
|
getLangOptions().SkipNonExportableDecls;
|
||||||
|
|
||||||
|
serializationOpts.SkipImplementationOnlyDecls =
|
||||||
|
getLangOptions().hasFeature(Feature::CheckImplementationOnly);
|
||||||
|
|
||||||
serializationOpts.ExplicitModuleBuild = FrontendOpts.DisableImplicitModules;
|
serializationOpts.ExplicitModuleBuild = FrontendOpts.DisableImplicitModules;
|
||||||
|
|
||||||
serializationOpts.EnableSerializationRemarks =
|
serializationOpts.EnableSerializationRemarks =
|
||||||
|
|||||||
@@ -5390,6 +5390,20 @@ bool Serializer::shouldSkipDecl(const Decl *D) const {
|
|||||||
void Serializer::writeASTBlockEntity(const Decl *D) {
|
void Serializer::writeASTBlockEntity(const Decl *D) {
|
||||||
using namespace decls_block;
|
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);
|
PrettyStackTraceDecl trace("serializing", D);
|
||||||
assert(DeclsToSerialize.hasRef(D));
|
assert(DeclsToSerialize.hasRef(D));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user