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 | 3ea7269b54aefd674424cd89be5f17ea8e18d222 (patch) | |
tree | 7c12465cfda3fd11deb868868016a61f9b0d6baf /clang/lib/AST/ASTContext.cpp | |
parent | 1ec8114eb82162e8dc25eb3ff020bf0f3bf8b88b (diff) | |
download | bcm5719-llvm-3ea7269b54aefd674424cd89be5f17ea8e18d222.tar.gz bcm5719-llvm-3ea7269b54aefd674424cd89be5f17ea8e18d222.zip |
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.
llvm-svn: 137429
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index c4955721e96..cf4535bd90c 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/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) { |