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 6e49d3b..95cab68 100644
--- a/include/clang/AST/DeclObjC.h
+++ b/include/clang/AST/DeclObjC.h
@@ -1306,7 +1306,7 @@
enum PropertyControl { None, Required, Optional };
private:
SourceLocation AtLoc; // location of @property
- QualType DeclType;
+ TypeSourceInfo *DeclType;
unsigned PropertyAttributes : 8;
// @required/@optional
@@ -1320,7 +1320,7 @@
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 @@
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 3ccded2..14fe980 100644
--- a/lib/AST/ASTImporter.cpp
+++ b/lib/AST/ASTImporter.cpp
@@ -2601,8 +2601,8 @@
}
// 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 dc4aacd..335e89b 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -887,7 +887,7 @@
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 8b7b66c..5056f93 100644
--- a/lib/Frontend/PCHReaderDecl.cpp
+++ b/lib/Frontend/PCHReaderDecl.cpp
@@ -376,7 +376,7 @@
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 @@
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 8eeef7c..499a16a 100644
--- a/lib/Frontend/PCHWriterDecl.cpp
+++ b/lib/Frontend/PCHWriterDecl.cpp
@@ -359,7 +359,7 @@
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 09d813c..6d3dcbc 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -1598,7 +1598,7 @@
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 @@
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 4c89a11..4200eb9 100644
--- a/lib/Sema/SemaObjCProperty.cpp
+++ b/lib/Sema/SemaObjCProperty.cpp
@@ -41,7 +41,8 @@
!(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 @@
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 @@
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 @@
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 @@
DeclContext *DC = cast<DeclContext>(CDecl);
ObjCPropertyDecl *PDecl = ObjCPropertyDecl::Create(Context, DC,
FD.D.getIdentifierLoc(),
- PropertyId, AtLoc, T);
+ PropertyId, AtLoc, TInfo);
if (ObjCPropertyDecl *prevDecl =
ObjCPropertyDecl::findPropertyDecl(DC, PropertyId)) {