summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2009-03-05 20:12:00 +0000
committerSteve Naroff <snaroff@apple.com>2009-03-05 20:12:00 +0000
commite29c4dd02238ad794f2348e27ba89b5aac90bb6a (patch)
treed514599a360b22e07e96b8a46e127b9781e72446 /clang/lib
parent631c5818ab34a1111612a9599fb653f4e1f0dfba (diff)
downloadbcm5719-llvm-e29c4dd02238ad794f2348e27ba89b5aac90bb6a.tar.gz
bcm5719-llvm-e29c4dd02238ad794f2348e27ba89b5aac90bb6a.zip
Partial fix <rdar://problem/6301205> [irgen] dot-syntax on super isn't supported.
Tweak Sema::ActOnMemberReferenceExpr() and Sema::ActOnDeclarationNameExpr() to handle "super." notation for Class methods. llvm-svn: 66185
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index f71f82daa90..8630da3c3f1 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -673,8 +673,13 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc,
}
// Needed to implement property "super.method" notation.
if (D == 0 && II->isStr("super")) {
- QualType T = Context.getPointerType(Context.getObjCInterfaceType(
- getCurMethodDecl()->getClassInterface()));
+ QualType T;
+
+ if (getCurMethodDecl()->isInstanceMethod())
+ T = Context.getPointerType(Context.getObjCInterfaceType(
+ getCurMethodDecl()->getClassInterface()));
+ else
+ T = Context.getObjCClassType();
return Owned(new (Context) ObjCSuperExpr(Loc, T));
}
}
@@ -1956,6 +1961,24 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc,
return ExprError(Diag(MemberLoc, diag::err_property_not_found)
<< &Member << BaseType);
}
+ // Handle properties on ObjC 'Class' types.
+ if (OpKind == tok::period && (BaseType == Context.getObjCClassType())) {
+ // Also must look for a getter name which uses property syntax.
+ Selector Sel = PP.getSelectorTable().getNullarySelector(&Member);
+ if (ObjCMethodDecl *MD = getCurMethodDecl()) {
+ ObjCMethodDecl *OMD;
+ // FIXME: need to also look locally in the implementation.
+ if ((OMD = MD->getClassInterface()->lookupClassMethod(Sel))) {
+ // Check the use of this method.
+ if (DiagnoseUseOfDecl(OMD, MemberLoc))
+ return ExprError();
+
+ return Owned(new (Context) ObjCMessageExpr(BaseExpr, Sel,
+ OMD->getResultType(), OMD, OpLoc, MemberLoc, NULL, 0));
+ }
+ }
+ }
+
// Handle 'field access' to vectors, such as 'V.xx'.
if (BaseType->isExtVectorType()) {
QualType ret = CheckExtVectorComponent(BaseType, OpLoc, Member, MemberLoc);
OpenPOWER on IntegriCloud