aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2008-11-25 17:56:43 +0000
committerFariborz Jahanian <fjahanian@apple.com>2008-11-25 17:56:43 +0000
commit6669db9d80d77d10f101aa9f8e488bbd2d98f76c (patch)
tree054665d87efaa4d5332407db5e4c1d264ebd5cb9 /lib
parentc9ad94e12aaf667e02c7297a663fc93090e1d2cb (diff)
Patch to allow over-riding of readonly property to
a writable property in one of its category. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60035 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/AST/Expr.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 835a467fc2..56f08b28d9 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -551,14 +551,28 @@ Expr::isModifiableLvalueResult Expr::isModifiableLvalue(ASTContext &Ctx) const {
if (getStmtClass() == ObjCPropertyRefExprClass) {
const ObjCPropertyRefExpr* PropExpr = cast<ObjCPropertyRefExpr>(this);
if (ObjCPropertyDecl *PDecl = PropExpr->getProperty()) {
- ObjCPropertyDecl::PropertyAttributeKind Pkind =
- PDecl->getPropertyAttributes();
- if (Pkind == ObjCPropertyDecl::OBJC_PR_readonly)
+ if (PDecl->isReadOnly()) {
+ // Main class has the property as 'readyonly'. Must search
+ // through the category list to see if the property's
+ // attribute has been over-ridden to 'readwrite'.
+ const Expr *BaseExpr = PropExpr->getBase();
+ QualType BaseType = BaseExpr->getType();
+ const PointerType *PTy = BaseType->getAsPointerType();
+ const ObjCInterfaceType *IFTy =
+ PTy->getPointeeType()->getAsObjCInterfaceType();
+ ObjCInterfaceDecl *IFace = IFTy->getDecl();
+ for (ObjCCategoryDecl *Category = IFace->getCategoryList();
+ Category; Category = Category->getNextClassCategory()) {
+ PDecl= Category->FindPropertyDeclaration(PDecl->getIdentifier());
+ if (PDecl && !PDecl->isReadOnly())
+ return MLV_Valid;
+ }
return MLV_ReadonlyProperty;
+ }
}
}
// Assigning to an 'implicit' property?
- if (getStmtClass() == ObjCKVCRefExprClass) {
+ else if (getStmtClass() == ObjCKVCRefExprClass) {
const ObjCKVCRefExpr* KVCExpr = cast<ObjCKVCRefExpr>(this);
if (KVCExpr->getSetterMethod() == 0)
return MLV_NoSetterProperty;