diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2009-01-09 01:04:21 +0000 |
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2009-01-09 01:04:21 +0000 |
| commit | f4c6616d9dd65a0c364d80ade1dd5618457e8d82 (patch) | |
| tree | 750fbea9dc0e2c5fa45fdf769283c3bec00bff7c /clang/lib/AST | |
| parent | a3491665a6576c017a25b466ec01d2ca5acc64d8 (diff) | |
| download | bcm5719-llvm-f4c6616d9dd65a0c364d80ade1dd5618457e8d82.tar.gz bcm5719-llvm-f4c6616d9dd65a0c364d80ade1dd5618457e8d82.zip | |
Fix crash on null deference when searching for readwrite properties in
categories.
- Also, simplify nesting via early return.
llvm-svn: 61968
Diffstat (limited to 'clang/lib/AST')
| -rw-r--r-- | clang/lib/AST/DeclObjC.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp index 194544f9fa8..cf3bd0abeaf 100644 --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/lib/AST/DeclObjC.cpp @@ -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. /// 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; + if (!PDecl->isReadOnly()) + return false; + + // Main class has the property as 'readonly'. 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()) { + ObjCPropertyDecl *P = + Category->FindPropertyDeclaration(PDecl->getIdentifier()); + if (P && !P->isReadOnly()) + return false; } - return false; + + return true; } /// FindPropertyDeclaration - Finds declaration of the property given its name |

