diff options
author | Steve Naroff <snaroff@apple.com> | 2008-06-05 13:55:23 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2008-06-05 13:55:23 +0000 |
commit | 3d2c22b1d334fa74d26a5f21841cb55df5dfdd1a (patch) | |
tree | b2d2f2ef087bf76fce4b108aae926887dc926b56 /lib/AST/DeclObjC.cpp | |
parent | 686226b538e72c5059ab7c9a8f87eb883193b645 (diff) |
Fix <rdar://problem/5987482> clang on xcode: null dereference in Sema::ActOnMemberReferenceExpr.
In addition to fixing the crasher, this commit fixes further improves property lookup (by searching protocols of qualified interfaces..."NSObject <prot>").
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52001 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclObjC.cpp')
-rw-r--r-- | lib/AST/DeclObjC.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index e493d27ac3..6536df6e1e 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -157,6 +157,14 @@ ObjCPropertyDecl * if (property) return property; } + // Look through protocols. + for (ObjCInterfaceDecl::protocol_iterator I = protocol_begin(), + E = protocol_end(); I != E; ++I) { + ObjCProtocolDecl *Protocol = *I; + ObjCPropertyDecl *property = Protocol->FindPropertyDeclaration(PropertyId); + if (property) + return property; + } if (getSuperClass()) return getSuperClass()->FindPropertyDeclaration(PropertyId); return 0; @@ -397,6 +405,20 @@ ObjCCategoryDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const { return 0; } +/// FindPropertyDeclaration - Finds declaration of the property given its name +/// in 'PropertyId' and returns it. It returns 0, if not found. +/// +ObjCPropertyDecl * +ObjCProtocolDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const { + for (ObjCProtocolDecl::classprop_iterator I = classprop_begin(), + E = classprop_end(); I != E; ++I) { + ObjCPropertyDecl *property = *I; + if (property->getIdentifier() == PropertyId) + return property; + } + return 0; +} + ObjCIvarDecl *ObjCInterfaceDecl::lookupInstanceVariable( IdentifierInfo *ID, ObjCInterfaceDecl *&clsDeclared) { ObjCInterfaceDecl* ClassDecl = this; |