diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-09-08 01:46:34 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-09-08 01:46:34 +0000 |
commit | bab8a96f2f509218bc1a25d67bc182581d65e50e (patch) | |
tree | a994fe755cc4162606d8c860ed630e2d5b1d9aaf /clang/lib/AST/ASTContext.cpp | |
parent | af3d4af4ebec2c519823a745665729ded3f9bbce (diff) | |
download | bcm5719-llvm-bab8a96f2f509218bc1a25d67bc182581d65e50e.tar.gz bcm5719-llvm-bab8a96f2f509218bc1a25d67bc182581d65e50e.zip |
Implement the Objective-C 'instancetype' type, which is an alias of
'id' that can be used (only!) via a contextual keyword as the result
type of an Objective-C message send. 'instancetype' then gives the
method a related result type, which we have already been inferring for
a variety of methods (new, alloc, init, self, retain). Addresses
<rdar://problem/9267640>.
llvm-svn: 139275
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index c3008944569..3a3fba5d61d 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -225,7 +225,7 @@ ASTContext::ASTContext(LangOptions& LOpts, SourceManager &SM, GlobalNestedNameSpecifier(0), Int128Decl(0), UInt128Decl(0), ObjCIdDecl(0), ObjCSelDecl(0), ObjCClassDecl(0), - CFConstantStringTypeDecl(0), + CFConstantStringTypeDecl(0), ObjCInstanceTypeDecl(0), FILEDecl(0), jmp_bufDecl(0), sigjmp_bufDecl(0), BlockDescriptorType(0), BlockDescriptorExtendedType(0), cudaConfigureCallDecl(0), @@ -3844,6 +3844,17 @@ ASTContext::BuildByRefType(StringRef DeclName, QualType Ty) const { return getPointerType(getTagDeclType(T)); } +TypedefDecl *ASTContext::getObjCInstanceTypeDecl() { + if (!ObjCInstanceTypeDecl) + ObjCInstanceTypeDecl = TypedefDecl::Create(*this, + getTranslationUnitDecl(), + SourceLocation(), + SourceLocation(), + &Idents.get("instancetype"), + getTrivialTypeSourceInfo(getObjCIdType())); + return ObjCInstanceTypeDecl; +} + // This returns true if a type has been typedefed to BOOL: // typedef <type> BOOL; static bool isTypeTypedefedAsBOOL(QualType T) { |