summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/AST/DeclObjC.h11
-rw-r--r--clang/lib/AST/DeclObjC.cpp3
-rw-r--r--clang/lib/Frontend/PCHReaderDecl.cpp4
-rw-r--r--clang/lib/Frontend/PCHWriterDecl.cpp1
-rw-r--r--clang/lib/Frontend/RewriteObjC.cpp7
-rw-r--r--clang/lib/Sema/SemaDeclObjC.cpp3
-rw-r--r--clang/test/Rewriter/rewrite-protocol-type-1.m3
7 files changed, 24 insertions, 8 deletions
diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h
index 1b25b40ff23..072bff8d0f1 100644
--- a/clang/include/clang/AST/DeclObjC.h
+++ b/clang/include/clang/AST/DeclObjC.h
@@ -1204,6 +1204,7 @@ public:
enum SetterKind { Assign, Retain, Copy };
enum PropertyControl { None, Required, Optional };
private:
+ SourceLocation AtLoc; // location of @propery
QualType DeclType;
unsigned PropertyAttributes : 8;
@@ -1218,8 +1219,8 @@ private:
ObjCIvarDecl *PropertyIvarDecl; // Synthesize ivar for this property
ObjCPropertyDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
- QualType T)
- : NamedDecl(ObjCProperty, DC, L, Id), DeclType(T),
+ SourceLocation AtLocation, QualType T)
+ : NamedDecl(ObjCProperty, DC, L, Id), AtLoc(AtLocation), DeclType(T),
PropertyAttributes(OBJC_PR_noattr), PropertyImplementation(None),
GetterName(Selector()),
SetterName(Selector()),
@@ -1227,8 +1228,12 @@ private:
public:
static ObjCPropertyDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L,
- IdentifierInfo *Id, QualType T,
+ IdentifierInfo *Id, SourceLocation AtLocation,
+ QualType 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; }
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp
index 40cbfd2d006..ffda505aaab 100644
--- a/clang/lib/AST/DeclObjC.cpp
+++ b/clang/lib/AST/DeclObjC.cpp
@@ -790,9 +790,10 @@ ObjCCompatibleAliasDecl::Create(ASTContext &C, DeclContext *DC,
ObjCPropertyDecl *ObjCPropertyDecl::Create(ASTContext &C, DeclContext *DC,
SourceLocation L,
IdentifierInfo *Id,
+ SourceLocation AtLoc,
QualType T,
PropertyControl propControl) {
- return new (C) ObjCPropertyDecl(DC, L, Id, T);
+ return new (C) ObjCPropertyDecl(DC, L, Id, AtLoc, T);
}
diff --git a/clang/lib/Frontend/PCHReaderDecl.cpp b/clang/lib/Frontend/PCHReaderDecl.cpp
index 8268bb2b511..4dc1318a3ee 100644
--- a/clang/lib/Frontend/PCHReaderDecl.cpp
+++ b/clang/lib/Frontend/PCHReaderDecl.cpp
@@ -326,6 +326,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++]));
// FIXME: stable encoding
D->setPropertyAttributes(
@@ -705,7 +706,8 @@ Decl *PCHReader::ReadDeclRecord(uint64_t Offset, unsigned Index) {
D = ObjCCompatibleAliasDecl::Create(*Context, 0, SourceLocation(), 0, 0);
break;
case pch::DECL_OBJC_PROPERTY:
- D = ObjCPropertyDecl::Create(*Context, 0, SourceLocation(), 0, QualType());
+ D = ObjCPropertyDecl::Create(*Context, 0, SourceLocation(), 0, SourceLocation(),
+ QualType());
break;
case pch::DECL_OBJC_PROPERTY_IMPL:
D = ObjCPropertyImplDecl::Create(*Context, 0, SourceLocation(),
diff --git a/clang/lib/Frontend/PCHWriterDecl.cpp b/clang/lib/Frontend/PCHWriterDecl.cpp
index 068fd41a826..020f69b3e66 100644
--- a/clang/lib/Frontend/PCHWriterDecl.cpp
+++ b/clang/lib/Frontend/PCHWriterDecl.cpp
@@ -315,6 +315,7 @@ void PCHDeclWriter::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D) {
void PCHDeclWriter::VisitObjCPropertyDecl(ObjCPropertyDecl *D) {
VisitNamedDecl(D);
+ Writer.AddSourceLocation(D->getAtLoc(), Record);
Writer.AddTypeRef(D->getType(), Record);
// FIXME: stable encoding
Record.push_back((unsigned)D->getPropertyAttributes());
diff --git a/clang/lib/Frontend/RewriteObjC.cpp b/clang/lib/Frontend/RewriteObjC.cpp
index 87229f9f916..35d8dde8eaa 100644
--- a/clang/lib/Frontend/RewriteObjC.cpp
+++ b/clang/lib/Frontend/RewriteObjC.cpp
@@ -833,6 +833,10 @@ void RewriteObjC::RewriteForwardClassDecl(ObjCClassDecl *ClassDecl) {
}
void RewriteObjC::RewriteMethodDeclaration(ObjCMethodDecl *Method) {
+ // When method is a synthesized one, such as a getter/setter there is
+ // nothing to rewrite.
+ if (Method->isSynthesized())
+ return;
SourceLocation LocStart = Method->getLocStart();
SourceLocation LocEnd = Method->getLocEnd();
@@ -846,10 +850,9 @@ void RewriteObjC::RewriteMethodDeclaration(ObjCMethodDecl *Method) {
}
void RewriteObjC::RewriteProperty(ObjCPropertyDecl *prop) {
- SourceLocation Loc = prop->getLocation();
+ SourceLocation Loc = prop->getAtLoc();
ReplaceText(Loc, 0, "// ", 3);
-
// FIXME: handle properties that are declared across multiple lines.
}
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index 3738b9c4fe8..1b07d19882e 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/lib/Sema/SemaDeclObjC.cpp
@@ -2186,7 +2186,8 @@ Sema::DeclPtrTy Sema::ActOnProperty(Scope *S, SourceLocation AtLoc,
assert(DC && "ClassDecl is not a DeclContext");
ObjCPropertyDecl *PDecl = ObjCPropertyDecl::Create(Context, DC,
FD.D.getIdentifierLoc(),
- FD.D.getIdentifier(), T);
+ FD.D.getIdentifier(),
+ AtLoc, T);
DeclContext::lookup_result Found = DC->lookup(PDecl->getDeclName());
if (Found.first != Found.second && isa<ObjCPropertyDecl>(*Found.first)) {
Diag(PDecl->getLocation(), diag::err_duplicate_property);
diff --git a/clang/test/Rewriter/rewrite-protocol-type-1.m b/clang/test/Rewriter/rewrite-protocol-type-1.m
index 902559dca60..2bdf8e46222 100644
--- a/clang/test/Rewriter/rewrite-protocol-type-1.m
+++ b/clang/test/Rewriter/rewrite-protocol-type-1.m
@@ -22,3 +22,6 @@ INTF <MyProto1, MyProto2> * Func1(INTF *p2, INTF<MyProto1, MyProto2> *p3, INTF *
return p3;
}
+@interface Foo
+@property int (*hashFunction)(const void *item, int (*size)(const void *item));
+@end
OpenPOWER on IntegriCloud