diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-08-12 05:46:01 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-08-12 05:46:01 +0000 |
commit | 4dfd02a17c6d604c72e6936527c5e1c56d3ecb7a (patch) | |
tree | 6ebd102cd1758abea2391ca34f4fdc0de0675326 /lib/AST/ASTContext.cpp | |
parent | 634a43c272a918f47cfc7dd07c7bd9481772f12e (diff) |
Move the creation of the predefined typedef for Objective-C's 'id'
type over into the AST context, then make that declaration a
predefined declaration in the AST format. This ensures that different
AST files will at least agree on the (global) declaration ID for 'id',
and eliminates one of the "special" types in the AST file format.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137429 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r-- | lib/AST/ASTContext.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index c4955721e9..cf4535bd90 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -222,7 +222,7 @@ ASTContext::ASTContext(const LangOptions& LOpts, SourceManager &SM, DependentTemplateSpecializationTypes(this_()), SubstTemplateTemplateParmPacks(this_()), GlobalNestedNameSpecifier(0), IsInt128Installed(false), - CFConstantStringTypeDecl(0), + ObjCIdDecl(0), CFConstantStringTypeDecl(0), FILEDecl(0), jmp_bufDecl(0), sigjmp_bufDecl(0), BlockDescriptorType(0), BlockDescriptorExtendedType(0), cudaConfigureCallDecl(0), @@ -430,7 +430,6 @@ void ASTContext::InitBuiltinTypes() { BuiltinVaListType = QualType(); // "Builtin" typedefs set by Sema::ActOnTranslationUnitScope(). - ObjCIdTypedefType = QualType(); ObjCClassTypedefType = QualType(); ObjCSelTypedefType = QualType(); @@ -4619,8 +4618,18 @@ void ASTContext::setBuiltinVaListType(QualType T) { BuiltinVaListType = T; } -void ASTContext::setObjCIdType(QualType T) { - ObjCIdTypedefType = T; +TypedefDecl *ASTContext::getObjCIdDecl() const { + if (!ObjCIdDecl) { + QualType T = getObjCObjectType(ObjCBuiltinIdTy, 0, 0); + T = getObjCObjectPointerType(T); + TypeSourceInfo *IdInfo = getTrivialTypeSourceInfo(T); + ObjCIdDecl = TypedefDecl::Create(const_cast<ASTContext &>(*this), + getTranslationUnitDecl(), + SourceLocation(), SourceLocation(), + &Idents.get("id"), IdInfo); + } + + return ObjCIdDecl; } void ASTContext::setObjCSelType(QualType T) { |