mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
AST: Refactor get*UnsafePointerDecl() lookups onto the AST context.
These types are needed by enough of the stack now that it makes sense to centralize their lookup and caching onto the AST context like other core types. Swift SVN r19029
This commit is contained in:
@@ -83,6 +83,15 @@ struct ASTContext::Implementation {
|
||||
/// The declaration of Swift.ImplicitlyUnwrappedOptional<T>.None.
|
||||
EnumElementDecl *ImplicitlyUnwrappedOptionalNoneDecl = nullptr;
|
||||
|
||||
/// The declaration of Swift.UnsafePointer<T>.
|
||||
NominalTypeDecl *UnsafePointerDecl = nullptr;
|
||||
|
||||
/// The declaration of Swift.ConstUnsafePointer<T>.
|
||||
NominalTypeDecl *ConstUnsafePointerDecl = nullptr;
|
||||
|
||||
/// The declaration of Swift.AutoreleasingUnsafePointer<T>.
|
||||
NominalTypeDecl *AutoreleasingUnsafePointerDecl = nullptr;
|
||||
|
||||
// Declare cached declarations for each of the known declarations.
|
||||
#define FUNC_DECL(Name, Id) FuncDecl *Get##Name = nullptr;
|
||||
#include "swift/AST/KnownDecls.def"
|
||||
@@ -520,6 +529,29 @@ EnumElementDecl *ASTContext::getImplicitlyUnwrappedOptionalNoneDecl() const {
|
||||
return Impl.ImplicitlyUnwrappedOptionalNoneDecl;
|
||||
}
|
||||
|
||||
NominalTypeDecl *ASTContext::getUnsafePointerDecl() const {
|
||||
if (!Impl.UnsafePointerDecl)
|
||||
Impl.UnsafePointerDecl = findSyntaxSugarImpl(*this, "UnsafePointer");
|
||||
|
||||
return Impl.UnsafePointerDecl;
|
||||
}
|
||||
|
||||
NominalTypeDecl *ASTContext::getConstUnsafePointerDecl() const {
|
||||
if (!Impl.ConstUnsafePointerDecl)
|
||||
Impl.ConstUnsafePointerDecl
|
||||
= findSyntaxSugarImpl(*this, "ConstUnsafePointer");
|
||||
|
||||
return Impl.ConstUnsafePointerDecl;
|
||||
}
|
||||
|
||||
NominalTypeDecl *ASTContext::getAutoreleasingUnsafePointerDecl() const {
|
||||
if (!Impl.AutoreleasingUnsafePointerDecl)
|
||||
Impl.AutoreleasingUnsafePointerDecl
|
||||
= findSyntaxSugarImpl(*this, "AutoreleasingUnsafePointer");
|
||||
|
||||
return Impl.AutoreleasingUnsafePointerDecl;
|
||||
}
|
||||
|
||||
ProtocolDecl *ASTContext::getProtocol(KnownProtocolKind kind) const {
|
||||
// Check whether we've already looked for and cached this protocol.
|
||||
unsigned index = (unsigned)kind;
|
||||
|
||||
Reference in New Issue
Block a user