Add @_neverEmitIntoClient to prohibit SIL serialization for a function

Part of the Embedded Swift linkage model, this attribute ensures that
the function it applies to has a strong definition in its owning
module, and that its SIL is never serialized. That way, other modules
will not have access to its definition.

Implements rdar://158364184.
This commit is contained in:
Doug Gregor
2025-08-17 23:21:57 -07:00
parent 9a20ebac5b
commit 2f60d729f0
10 changed files with 118 additions and 1 deletions

View File

@@ -3575,6 +3575,12 @@ bool SILSerializer::shouldEmitFunctionBody(const SILFunction *F,
if (F->isAvailableExternally())
return false;
if (F->getDeclRef().hasDecl()) {
if (auto decl = F->getDeclRef().getDecl())
if (decl->isNeverEmittedIntoClient())
return false;
}
// If we are asked to serialize everything, go ahead and do it.
if (ShouldSerializeAll)
return true;