[cfe-commits] r68527 - in /cfe/trunk: lib/Sema/Sema.h lib/Sema/SemaExpr.cpp test/SemaObjC/property-method-lookup-impl.m
Fariborz Jahanian
fjahanian at apple.com
Tue Apr 7 11:28:06 PDT 2009
Author: fjahanian
Date: Tue Apr 7 13:28:06 2009
New Revision: 68527
URL: http://llvm.org/viewvc/llvm-project?rev=68527&view=rev
Log:
Fixes method name lookup when method appears in
the base implementations (and not in
current implementation).
Added:
cfe/trunk/test/SemaObjC/property-method-lookup-impl.m
Modified:
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=68527&r1=68526&r2=68527&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Tue Apr 7 13:28:06 2009
@@ -950,6 +950,9 @@
std::pair<bool, LookupResult> CppLookupName(Scope *S, DeclarationName Name,
LookupNameKind NameKind,
bool RedeclarationOnly);
+ ObjCMethodDecl *FindMethodInNestedImplementations(
+ const ObjCInterfaceDecl *IFace,
+ const Selector &Sel);
public:
/// Determines whether D is a suitable lookup result according to the
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=68527&r1=68526&r2=68527&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Apr 7 13:28:06 2009
@@ -1739,6 +1739,22 @@
return GDecl;
}
+/// FindMethodInNestedImplementations - Look up a method in current and
+/// all base class implementations.
+///
+ObjCMethodDecl *Sema::FindMethodInNestedImplementations(
+ const ObjCInterfaceDecl *IFace,
+ const Selector &Sel) {
+ ObjCMethodDecl *Method = 0;
+ if (ObjCImplementationDecl *ImpDecl =
+ Sema::ObjCImplementations[IFace->getIdentifier()])
+ Method = ImpDecl->getInstanceMethod(Sel);
+
+ if (!Method && IFace->getSuperClass())
+ return FindMethodInNestedImplementations(IFace->getSuperClass(), Sel);
+ return Method;
+}
+
Action::OwningExprResult
Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
tok::TokenKind OpKind, SourceLocation MemberLoc,
@@ -1953,9 +1969,7 @@
// If this reference is in an @implementation, check for 'private' methods.
if (!Getter)
- if (ObjCImplementationDecl *ImpDecl =
- ObjCImplementations[IFace->getIdentifier()])
- Getter = ImpDecl->getInstanceMethod(Sel);
+ Getter = FindMethodInNestedImplementations(IFace, Sel);
// Look through local category implementations associated with the class.
if (!Getter) {
@@ -1978,9 +1992,7 @@
if (!Setter) {
// If this reference is in an @implementation, also check for 'private'
// methods.
- if (ObjCImplementationDecl *ImpDecl =
- ObjCImplementations[IFace->getIdentifier()])
- Setter = ImpDecl->getInstanceMethod(SetterSel);
+ Setter = FindMethodInNestedImplementations(IFace, SetterSel);
}
// Look through local category implementations associated with the class.
if (!Setter) {
@@ -2061,9 +2073,7 @@
if (!Setter) {
// If this reference is in an @implementation, also check for 'private'
// methods.
- if (ObjCImplementationDecl *ImpDecl =
- ObjCImplementations[IFace->getIdentifier()])
- Setter = ImpDecl->getInstanceMethod(SetterSel);
+ Setter = FindMethodInNestedImplementations(IFace, SetterSel);
}
// Look through local category implementations associated with the class.
if (!Setter) {
Added: cfe/trunk/test/SemaObjC/property-method-lookup-impl.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-method-lookup-impl.m?rev=68527&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/property-method-lookup-impl.m (added)
+++ cfe/trunk/test/SemaObjC/property-method-lookup-impl.m Tue Apr 7 13:28:06 2009
@@ -0,0 +1,26 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+ at interface SSyncCEList
+{
+ id _list;
+}
+ at end
+
+ at implementation SSyncCEList
+
+- (id) list
+{
+}
+ at end
+
+ at interface SSyncConflictList : SSyncCEList
+ at end
+
+ at implementation SSyncConflictList
+
+- (id)Meth : (SSyncConflictList*)other
+ {
+ return other.list;
+ }
+ at end
+
More information about the cfe-commits
mailing list