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
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index e493d27..6536df6 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -157,6 +157,14 @@
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 @@
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;