mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Add @_implements decl attribute.
This commit is contained in:
@@ -267,6 +267,11 @@ SIMPLE_DECL_ATTR(discardableResult, DiscardableResult,
|
||||
|
||||
SIMPLE_DECL_ATTR(GKInspectable, GKInspectable, OnVar, 66)
|
||||
|
||||
DECL_ATTR(_implements, Implements,
|
||||
OnFunc | OnVar | OnSubscript | OnTypeAlias
|
||||
| NotSerialized | UserInaccessible,
|
||||
/* Not serialized */ 67)
|
||||
|
||||
#undef TYPE_ATTR
|
||||
#undef DECL_ATTR_ALIAS
|
||||
#undef SIMPLE_DECL_ATTR
|
||||
|
||||
@@ -25,10 +25,12 @@
|
||||
#include "swift/AST/Identifier.h"
|
||||
#include "swift/AST/AttrKind.h"
|
||||
#include "swift/AST/ConcreteDeclRef.h"
|
||||
#include "swift/AST/DeclNameLoc.h"
|
||||
#include "swift/AST/KnownProtocols.h"
|
||||
#include "swift/AST/Ownership.h"
|
||||
#include "swift/AST/PlatformKind.h"
|
||||
#include "swift/AST/Requirement.h"
|
||||
#include "swift/AST/TypeLoc.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
@@ -43,7 +45,6 @@ class Decl;
|
||||
class ClassDecl;
|
||||
class GenericFunctionType;
|
||||
class TrailingWhereClause;
|
||||
struct TypeLoc;
|
||||
|
||||
/// TypeAttributes - These are attributes that may be applied to types.
|
||||
class TypeAttributes {
|
||||
@@ -1127,6 +1128,36 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/// The @_implements attribute, which treats a decl as the implementation for
|
||||
/// some named protocol requirement (but otherwise not-visible by that name).
|
||||
class ImplementsAttr : public DeclAttribute {
|
||||
|
||||
TypeLoc ProtocolType;
|
||||
DeclName MemberName;
|
||||
DeclNameLoc MemberNameLoc;
|
||||
|
||||
public:
|
||||
ImplementsAttr(SourceLoc atLoc, SourceRange Range,
|
||||
TypeLoc ProtocolType,
|
||||
DeclName MemberName,
|
||||
DeclNameLoc MemberNameLoc);
|
||||
|
||||
static ImplementsAttr *create(ASTContext &Ctx, SourceLoc atLoc,
|
||||
SourceRange Range,
|
||||
TypeLoc ProtocolType,
|
||||
DeclName MemberName,
|
||||
DeclNameLoc MemberNameLoc);
|
||||
|
||||
TypeLoc getProtocolType() const;
|
||||
TypeLoc &getProtocolType();
|
||||
DeclName getMemberName() const { return MemberName; }
|
||||
DeclNameLoc getMemberNameLoc() const { return MemberNameLoc; }
|
||||
|
||||
static bool classof(const DeclAttribute *DA) {
|
||||
return DA->getKind() == DAK_Implements;
|
||||
}
|
||||
};
|
||||
|
||||
/// \brief Attributes that may be applied to declarations.
|
||||
class DeclAttributes {
|
||||
/// Linked list of declaration attributes.
|
||||
|
||||
@@ -1310,6 +1310,7 @@ namespace decls_block {
|
||||
using ObjCBridgedDeclAttrLayout = BCRecordLayout<ObjCBridged_DECL_ATTR>;
|
||||
using SynthesizedProtocolDeclAttrLayout
|
||||
= BCRecordLayout<SynthesizedProtocol_DECL_ATTR>;
|
||||
using ImplementsDeclAttrLayout = BCRecordLayout<Implements_DECL_ATTR>;
|
||||
|
||||
using InlineDeclAttrLayout = BCRecordLayout<
|
||||
Inline_DECL_ATTR,
|
||||
|
||||
Reference in New Issue
Block a user