Inherit access control in @abi

ABI-only declarations now inherit access control modifiers like `public` or `private(set)`, as well as `@usableFromInline` and `@_spi`, from their API counterpart. This means these attributes and modifiers don’t need to be specified in an `@abi` attribute.

Very few tests because we aren’t yet enforcing the absence of these attributes.
This commit is contained in:
Becca Royal-Gordon
2025-03-12 16:48:20 -07:00
parent 1bb2186377
commit 9be9b6fad6
4 changed files with 23 additions and 2 deletions

View File

@@ -3165,6 +3165,11 @@ SPIGroupsRequest::evaluate(Evaluator &evaluator, const Decl *decl) const {
assert (isa<ValueDecl>(decl) ||
isa<ExtensionDecl>(decl));
// ABI decls share the SPI groups of their API decl.
auto abiRole = ABIRoleInfo(decl);
if (!abiRole.providesAPI() && abiRole.getCounterpart())
return abiRole.getCounterpart()->getSPIGroups();
// First, look for local attributes.
llvm::SetVector<Identifier> spiGroups;
for (auto attr : decl->getAttrs().getAttributes<SPIAccessControlAttr>())