Skip to content
Snippets Groups Projects
Commit f4c6616d authored by Daniel Dunbar's avatar Daniel Dunbar
Browse files

Fix crash on null deference when searching for readwrite properties in

categories.
 - Also, simplify nesting via early return.

llvm-svn: 61968
parent a3491665
No related branches found
No related tags found
No related merge requests found
...@@ -252,24 +252,26 @@ void ObjCMethodDecl::setMethodParams(ParmVarDecl **NewParamInfo, ...@@ -252,24 +252,26 @@ void ObjCMethodDecl::setMethodParams(ParmVarDecl **NewParamInfo,
} }
} }
/// isPropertyReadonly - Return true if property is a readonly, by seaching /// isPropertyReadonly - Return true if property is readonly, by searching
/// for the property in the class and in its categories. /// for the property in the class and in its categories.
/// ///
bool ObjCInterfaceDecl::isPropertyReadonly(ObjCPropertyDecl *PDecl) const bool ObjCInterfaceDecl::isPropertyReadonly(ObjCPropertyDecl *PDecl) const
{ {
if (PDecl->isReadOnly()) { if (!PDecl->isReadOnly())
// Main class has the property as 'readyonly'. Must search return false;
// through the category list to see if the property's
// attribute has been over-ridden to 'readwrite'. // Main class has the property as 'readonly'. Must search
for (ObjCCategoryDecl *Category = getCategoryList(); // through the category list to see if the property's
Category; Category = Category->getNextClassCategory()) { // attribute has been over-ridden to 'readwrite'.
PDecl= Category->FindPropertyDeclaration(PDecl->getIdentifier()); for (ObjCCategoryDecl *Category = getCategoryList();
if (PDecl && !PDecl->isReadOnly()) Category; Category = Category->getNextClassCategory()) {
return false; ObjCPropertyDecl *P =
} Category->FindPropertyDeclaration(PDecl->getIdentifier());
return true; if (P && !P->isReadOnly())
return false;
} }
return false;
return true;
} }
/// FindPropertyDeclaration - Finds declaration of the property given its name /// FindPropertyDeclaration - Finds declaration of the property given its name
......
...@@ -33,3 +33,20 @@ int main(int argc, char **argv) { ...@@ -33,3 +33,20 @@ int main(int argc, char **argv) {
return test.object - 12345 + test.Anotherobject - 200; return test.object - 12345 + test.Anotherobject - 200;
} }
///
@interface I0
@property(readonly) int p0;
@end
@interface I0 (Cat0)
@end
@interface I0 (Cat1)
@end
@implementation I0
- (void) foo {
self.p0 = 0; // expected-error {{assigning to property with 'readonly' attribute not allowed}}
}
@end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment