mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[SILDeclRef] RuntimeMetadata: Add a special kind for runtime attribute generator
A new `RuntimeAttributeGenerator` is used to reference runtime attribute generator functions synthesized by SILGen. `#function` magic literal points to the declaration that declaration attribute is attached to.
This commit is contained in:
@@ -369,6 +369,7 @@ bool SILDeclRef::hasUserWrittenCode() const {
|
||||
case Kind::PropertyWrapperInitFromProjectedValue:
|
||||
case Kind::EntryPoint:
|
||||
case Kind::AsyncEntryPoint:
|
||||
case Kind::RuntimeAttributeGenerator:
|
||||
// Implicit decls for these don't splice in user-written code.
|
||||
return false;
|
||||
}
|
||||
@@ -510,6 +511,9 @@ static LinkageLimit getLinkageLimit(SILDeclRef constant) {
|
||||
// class from which they come, and never get seen externally.
|
||||
return Limit::NeverPublic;
|
||||
|
||||
case Kind::RuntimeAttributeGenerator:
|
||||
return Limit::NeverPublic;
|
||||
|
||||
case Kind::EntryPoint:
|
||||
case Kind::AsyncEntryPoint:
|
||||
llvm_unreachable("Already handled");
|
||||
@@ -671,6 +675,16 @@ SILDeclRef SILDeclRef::getMainFileEntryPoint(FileUnit *file) {
|
||||
return result;
|
||||
}
|
||||
|
||||
SILDeclRef SILDeclRef::getRuntimeAttributeGenerator(CustomAttr *attr,
|
||||
ValueDecl *decl) {
|
||||
SILDeclRef result;
|
||||
result.loc = decl;
|
||||
result.kind = Kind::RuntimeAttributeGenerator;
|
||||
result.isRuntimeAccessible = true;
|
||||
result.pointer = attr;
|
||||
return result;
|
||||
}
|
||||
|
||||
bool SILDeclRef::hasClosureExpr() const {
|
||||
return loc.is<AbstractClosureExpr *>()
|
||||
&& isa<ClosureExpr>(getAbstractClosureExpr());
|
||||
@@ -1009,7 +1023,8 @@ bool SILDeclRef::isBackDeploymentThunk() const {
|
||||
}
|
||||
|
||||
bool SILDeclRef::isRuntimeAccessibleFunction() const {
|
||||
return isRuntimeAccessible && kind == Kind::Func;
|
||||
return isRuntimeAccessible &&
|
||||
(kind == Kind::Func || kind == Kind::RuntimeAttributeGenerator);
|
||||
}
|
||||
|
||||
/// Use the Clang importer to mangle a Clang declaration.
|
||||
@@ -1188,6 +1203,10 @@ std::string SILDeclRef::mangle(ManglingKind MKind) const {
|
||||
case SILDeclRef::Kind::EntryPoint: {
|
||||
return getASTContext().getEntryPointFunctionName();
|
||||
}
|
||||
|
||||
case SILDeclRef::Kind::RuntimeAttributeGenerator:
|
||||
return mangler.mangleRuntimeAttributeGeneratorEntity(
|
||||
loc.get<ValueDecl *>(), pointer.get<CustomAttr *>(), SKind);
|
||||
}
|
||||
|
||||
llvm_unreachable("bad entity kind!");
|
||||
@@ -1556,7 +1575,7 @@ unsigned SILDeclRef::getParameterListCount() const {
|
||||
|
||||
// Always uncurried even if the underlying function is curried.
|
||||
if (kind == Kind::DefaultArgGenerator || kind == Kind::EntryPoint ||
|
||||
kind == Kind::AsyncEntryPoint)
|
||||
kind == Kind::AsyncEntryPoint || kind == Kind::RuntimeAttributeGenerator)
|
||||
return 1;
|
||||
|
||||
auto *vd = getDecl();
|
||||
|
||||
Reference in New Issue
Block a user