diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2008-11-25 21:48:26 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2008-11-25 21:48:26 +0000 |
commit | 829b908b748a94f0f48876e1dfa0ab4fae5a5260 (patch) | |
tree | e1babd7e861d750a7094d86b801f46d1177baa21 /clang/lib/AST | |
parent | e9eeb0d562870dc691aaae8fb53708ccf96bacbf (diff) | |
download | bcm5719-llvm-829b908b748a94f0f48876e1dfa0ab4fae5a5260.tar.gz bcm5719-llvm-829b908b748a94f0f48876e1dfa0ab4fae5a5260.zip |
Refactored checking on readonly property into a method.
llvm-svn: 60050
Diffstat (limited to 'clang/lib/AST')
-rw-r--r-- | clang/lib/AST/DeclObjC.cpp | 20 | ||||
-rw-r--r-- | clang/lib/AST/Expr.cpp | 25 |
2 files changed, 27 insertions, 18 deletions
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp index 040a9219087..e631bac452e 100644 --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/lib/AST/DeclObjC.cpp @@ -257,6 +257,26 @@ void ObjCMethodDecl::setMethodParams(ParmVarDecl **NewParamInfo, } } +/// isPropertyReadonly - Return true if property is a readonly, by seaching +/// for the property in the class and in its categories. +/// +bool ObjCInterfaceDecl::isPropertyReadonly(ObjCPropertyDecl *PDecl) const +{ + 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'. + for (ObjCCategoryDecl *Category = getCategoryList(); + Category; Category = Category->getNextClassCategory()) { + PDecl= Category->FindPropertyDeclaration(PDecl->getIdentifier()); + if (PDecl && !PDecl->isReadOnly()) + return false; + } + return true; + } + return false; +} + /// FindPropertyDeclaration - Finds declaration of the property given its name /// in 'PropertyId' and returns it. It returns 0, if not found. /// diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 56f08b28d95..7a8119c5e3d 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -551,24 +551,13 @@ Expr::isModifiableLvalueResult Expr::isModifiableLvalue(ASTContext &Ctx) const { if (getStmtClass() == ObjCPropertyRefExprClass) { const ObjCPropertyRefExpr* PropExpr = cast<ObjCPropertyRefExpr>(this); if (ObjCPropertyDecl *PDecl = PropExpr->getProperty()) { - 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; - } + QualType BaseType = PropExpr->getBase()->getType(); + if (const PointerType *PTy = BaseType->getAsPointerType()) + if (const ObjCInterfaceType *IFTy = + PTy->getPointeeType()->getAsObjCInterfaceType()) + if (ObjCInterfaceDecl *IFace = IFTy->getDecl()) + if (IFace->isPropertyReadonly(PDecl)) + return MLV_ReadonlyProperty; } } // Assigning to an 'implicit' property? |