[cfe-commits] r127367 - in /cfe/trunk: lib/Sema/SemaExprObjC.cpp test/SemaObjC/objc-qualified-property-lookup.m
Fariborz Jahanian
fjahanian at apple.com
Wed Mar 9 14:17:12 PST 2011
Author: fjahanian
Date: Wed Mar 9 16:17:12 2011
New Revision: 127367
URL: http://llvm.org/viewvc/llvm-project?rev=127367&view=rev
Log:
Property setter/getter must be looked up in property type's
list of protocols as well. // rdar://9078584
Added:
cfe/trunk/test/SemaObjC/objc-qualified-property-lookup.m
Modified:
cfe/trunk/lib/Sema/SemaExprObjC.cpp
Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=127367&r1=127366&r2=127367&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Wed Mar 9 16:17:12 2011
@@ -465,6 +465,10 @@
Selector Sel = PP.getSelectorTable().getNullarySelector(Member);
ObjCMethodDecl *Getter = IFace->lookupInstanceMethod(Sel);
+
+ // May be founf in property's qualified list.
+ if (!Getter)
+ Getter = LookupMethodInQualifiedType(Sel, OPT, true);
// If this reference is in an @implementation, check for 'private' methods.
if (!Getter)
@@ -484,6 +488,11 @@
SelectorTable::constructSetterName(PP.getIdentifierTable(),
PP.getSelectorTable(), Member);
ObjCMethodDecl *Setter = IFace->lookupInstanceMethod(SetterSel);
+
+ // May be founf in property's qualified list.
+ if (!Setter)
+ Setter = LookupMethodInQualifiedType(SetterSel, OPT, true);
+
if (!Setter) {
// If this reference is in an @implementation, also check for 'private'
// methods.
@@ -492,7 +501,7 @@
// Look through local category implementations associated with the class.
if (!Setter)
Setter = IFace->getCategoryInstanceMethod(SetterSel);
-
+
if (Setter && DiagnoseUseOfDecl(Setter, MemberLoc))
return ExprError();
@@ -1087,15 +1096,9 @@
if (const ObjCObjectPointerType *QIdTy
= ReceiverType->getAsObjCQualifiedIdType()) {
// Search protocols for instance methods.
- for (ObjCObjectPointerType::qual_iterator I = QIdTy->qual_begin(),
- E = QIdTy->qual_end(); I != E; ++I) {
- ObjCProtocolDecl *PDecl = *I;
- if (PDecl && (Method = PDecl->lookupInstanceMethod(Sel)))
- break;
- // Since we aren't supporting "Class<foo>", look for a class method.
- if (PDecl && (Method = PDecl->lookupClassMethod(Sel)))
- break;
- }
+ Method = LookupMethodInQualifiedType(Sel, QIdTy, true);
+ if (!Method)
+ Method = LookupMethodInQualifiedType(Sel, QIdTy, false);
} else if (const ObjCObjectPointerType *OCIType
= ReceiverType->getAsObjCInterfacePointerType()) {
// We allow sending a message to a pointer to an interface (an object).
@@ -1105,14 +1108,10 @@
// The idea is to add class info to MethodPool.
Method = ClassDecl->lookupInstanceMethod(Sel);
- if (!Method) {
+ if (!Method)
// Search protocol qualifiers.
- for (ObjCObjectPointerType::qual_iterator QI = OCIType->qual_begin(),
- E = OCIType->qual_end(); QI != E; ++QI) {
- if ((Method = (*QI)->lookupInstanceMethod(Sel)))
- break;
- }
- }
+ Method = LookupMethodInQualifiedType(Sel, OCIType, true);
+
bool forwardClass = false;
if (!Method) {
// If we have implementations in scope, check "private" methods.
Added: cfe/trunk/test/SemaObjC/objc-qualified-property-lookup.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/objc-qualified-property-lookup.m?rev=127367&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/objc-qualified-property-lookup.m (added)
+++ cfe/trunk/test/SemaObjC/objc-qualified-property-lookup.m Wed Mar 9 16:17:12 2011
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://9078584
+
+ at interface NSObject @end
+
+ at protocol TextInput
+-editRange;
+ at end
+
+ at interface I {
+ NSObject<TextInput>* editor;
+}
+- (id) Meth;
+ at end
+
+ at implementation I
+- (id) Meth {
+ return editor.editRange;
+}
+ at end
+
More information about the cfe-commits
mailing list