Explicit declaration of property setters over-ride
prohibition of 'readonly' properties in an assignment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62028 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index 56da9a6..f39eec3 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -257,7 +257,9 @@
///
bool ObjCInterfaceDecl::isPropertyReadonly(ObjCPropertyDecl *PDecl) const
{
- if (!PDecl->isReadOnly())
+ // Even if property is ready only, if interface has a user defined setter,
+ // it is not considered read only.
+ if (!PDecl->isReadOnly() || getInstanceMethod(PDecl->getSetterName()))
return false;
// Main class has the property as 'readonly'. Must search
@@ -265,6 +267,10 @@
// attribute has been over-ridden to 'readwrite'.
for (ObjCCategoryDecl *Category = getCategoryList();
Category; Category = Category->getNextClassCategory()) {
+ // Even if property is ready only, if a category has a user defined setter,
+ // it is not considered read only.
+ if (Category->getInstanceMethod(PDecl->getSetterName()))
+ return false;
ObjCPropertyDecl *P =
Category->FindPropertyDeclaration(PDecl->getIdentifier());
if (P && !P->isReadOnly())