From: John McCall Date: Fri, 4 Jun 2010 20:50:08 +0000 (+0000) Subject: Remember type source information for Objective C property declarations. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=83a230c83a54190366138c1a4f4310ef838b88fc;p=clang Remember type source information for Objective C property declarations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105484 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index 6e49d3b835..95cab68d12 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -1306,7 +1306,7 @@ public: enum PropertyControl { None, Required, Optional }; private: SourceLocation AtLoc; // location of @property - QualType DeclType; + TypeSourceInfo *DeclType; unsigned PropertyAttributes : 8; // @required/@optional @@ -1320,7 +1320,7 @@ private: ObjCIvarDecl *PropertyIvarDecl; // Synthesize ivar for this property ObjCPropertyDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id, - SourceLocation AtLocation, QualType T) + SourceLocation AtLocation, TypeSourceInfo *T) : NamedDecl(ObjCProperty, DC, L, Id), AtLoc(AtLocation), DeclType(T), PropertyAttributes(OBJC_PR_noattr), PropertyImplementation(None), GetterName(Selector()), @@ -1330,13 +1330,14 @@ public: static ObjCPropertyDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, SourceLocation AtLocation, - QualType T, + TypeSourceInfo *T, PropertyControl propControl = None); SourceLocation getAtLoc() const { return AtLoc; } void setAtLoc(SourceLocation L) { AtLoc = L; } - QualType getType() const { return DeclType; } - void setType(QualType T) { DeclType = T; } + TypeSourceInfo *getTypeSourceInfo() const { return DeclType; } + QualType getType() const { return DeclType->getType(); } + void setType(TypeSourceInfo *T) { DeclType = T; } PropertyAttributeKind getPropertyAttributes() const { return PropertyAttributeKind(PropertyAttributes); diff --git a/lib/AST/ASTImporter.cpp b/lib/AST/ASTImporter.cpp index 3ccded28c4..14fe980575 100644 --- a/lib/AST/ASTImporter.cpp +++ b/lib/AST/ASTImporter.cpp @@ -2601,8 +2601,8 @@ Decl *ASTNodeImporter::VisitObjCPropertyDecl(ObjCPropertyDecl *D) { } // Import the type. - QualType T = Importer.Import(D->getType()); - if (T.isNull()) + TypeSourceInfo *T = Importer.Import(D->getTypeSourceInfo()); + if (!T) return 0; // Create the new property. diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index dc4aacdb51..335e89bada 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -887,7 +887,7 @@ ObjCPropertyDecl *ObjCPropertyDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, SourceLocation AtLoc, - QualType T, + TypeSourceInfo *T, PropertyControl propControl) { return new (C) ObjCPropertyDecl(DC, L, Id, AtLoc, T); } diff --git a/lib/Frontend/PCHReaderDecl.cpp b/lib/Frontend/PCHReaderDecl.cpp index 8b7b66c2b8..5056f93377 100644 --- a/lib/Frontend/PCHReaderDecl.cpp +++ b/lib/Frontend/PCHReaderDecl.cpp @@ -376,7 +376,7 @@ void PCHDeclReader::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *CAD) { void PCHDeclReader::VisitObjCPropertyDecl(ObjCPropertyDecl *D) { VisitNamedDecl(D); D->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++])); - D->setType(Reader.GetType(Record[Idx++])); + D->setType(Reader.GetTypeSourceInfo(Record, Idx)); // FIXME: stable encoding D->setPropertyAttributes( (ObjCPropertyDecl::PropertyAttributeKind)Record[Idx++]); @@ -1045,7 +1045,7 @@ Decl *PCHReader::ReadDeclRecord(uint64_t Offset, unsigned Index) { break; case pch::DECL_OBJC_PROPERTY: D = ObjCPropertyDecl::Create(*Context, 0, SourceLocation(), 0, SourceLocation(), - QualType()); + 0); break; case pch::DECL_OBJC_PROPERTY_IMPL: D = ObjCPropertyImplDecl::Create(*Context, 0, SourceLocation(), diff --git a/lib/Frontend/PCHWriterDecl.cpp b/lib/Frontend/PCHWriterDecl.cpp index 8eeef7c741..499a16adb1 100644 --- a/lib/Frontend/PCHWriterDecl.cpp +++ b/lib/Frontend/PCHWriterDecl.cpp @@ -359,7 +359,7 @@ void PCHDeclWriter::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D) { void PCHDeclWriter::VisitObjCPropertyDecl(ObjCPropertyDecl *D) { VisitNamedDecl(D); Writer.AddSourceLocation(D->getAtLoc(), Record); - Writer.AddTypeRef(D->getType(), Record); + Writer.AddTypeSourceInfo(D->getTypeSourceInfo(), Record); // FIXME: stable encoding Record.push_back((unsigned)D->getPropertyAttributes()); // FIXME: stable encoding diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index 09d813c7db..6d3dcbc8f0 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -1598,7 +1598,7 @@ public: const bool isReadWrite, const unsigned Attributes, bool *isOverridingProperty, - QualType T, + TypeSourceInfo *T, tok::ObjCKeywordKind MethodImplKind); /// Called by ActOnProperty and HandlePropertyInClassExtension to @@ -1611,7 +1611,8 @@ public: Selector SetterSel, const bool isAssign, const bool isReadWrite, - const unsigned Attributes, QualType T, + const unsigned Attributes, + TypeSourceInfo *T, tok::ObjCKeywordKind MethodImplKind, DeclContext *lexicalDC = 0); diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 4c89a118bc..4200eb9ad3 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -41,7 +41,8 @@ Sema::DeclPtrTy Sema::ActOnProperty(Scope *S, SourceLocation AtLoc, !(Attributes & ObjCDeclSpec::DQ_PR_retain) && !(Attributes & ObjCDeclSpec::DQ_PR_copy))); - QualType T = GetTypeForDeclarator(FD.D, S); + TypeSourceInfo *TSI = 0; + QualType T = GetTypeForDeclarator(FD.D, S, &TSI); if (T->isReferenceType()) { Diag(AtLoc, diag::error_reference_property); return DeclPtrTy(); @@ -56,13 +57,13 @@ Sema::DeclPtrTy Sema::ActOnProperty(Scope *S, SourceLocation AtLoc, FD, GetterSel, SetterSel, isAssign, isReadWrite, Attributes, - isOverridingProperty, T, + isOverridingProperty, TSI, MethodImplKind); DeclPtrTy Res = DeclPtrTy::make(CreatePropertyDecl(S, ClassDecl, AtLoc, FD, GetterSel, SetterSel, isAssign, isReadWrite, - Attributes, T, MethodImplKind)); + Attributes, TSI, MethodImplKind)); // Validate the attributes on the @property. CheckObjCPropertyAttributes(Res, AtLoc, Attributes); return Res; @@ -76,7 +77,7 @@ Sema::HandlePropertyInClassExtension(Scope *S, ObjCCategoryDecl *CDecl, const bool isReadWrite, const unsigned Attributes, bool *isOverridingProperty, - QualType T, + TypeSourceInfo *T, tok::ObjCKeywordKind MethodImplKind) { // Diagnose if this property is already in continuation class. @@ -190,11 +191,11 @@ ObjCPropertyDecl *Sema::CreatePropertyDecl(Scope *S, const bool isAssign, const bool isReadWrite, const unsigned Attributes, - QualType T, + TypeSourceInfo *TInfo, tok::ObjCKeywordKind MethodImplKind, DeclContext *lexicalDC){ - IdentifierInfo *PropertyId = FD.D.getIdentifier(); + QualType T = TInfo->getType(); // Issue a warning if property is 'assign' as default and its object, which is // gc'able conforms to NSCopying protocol @@ -215,7 +216,7 @@ ObjCPropertyDecl *Sema::CreatePropertyDecl(Scope *S, DeclContext *DC = cast(CDecl); ObjCPropertyDecl *PDecl = ObjCPropertyDecl::Create(Context, DC, FD.D.getIdentifierLoc(), - PropertyId, AtLoc, T); + PropertyId, AtLoc, TInfo); if (ObjCPropertyDecl *prevDecl = ObjCPropertyDecl::findPropertyDecl(DC, PropertyId)) {