diff options
author | Steve Naroff <snaroff@apple.com> | 2008-07-24 19:44:33 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2008-07-24 19:44:33 +0000 |
commit | fc93d52ada07d52de0ad4fd051b6a08e21d421ff (patch) | |
tree | 4ded457fe6093b022dd9d004e14a07345e055beb /lib/Sema/SemaExprObjC.cpp | |
parent | 17a61db7da06eec137f48bfb40369ec2a39c4fdc (diff) |
Fix Sema::ActOnClassMessage() to pass through the identifier for "super".
This fixes a critical rewriter bug (<rdar://problem/6096760> clang ObjC rewriter: 'self' not expected value in class method called with 'super').
Also added a couple FIXME's since I'm not happy with my fix to Sema. It would be nicer if the super handling for class/instance messages was the same (based on PreDefinedExpr).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53994 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprObjC.cpp')
-rw-r--r-- | lib/Sema/SemaExprObjC.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index 333268e8e5..5d168232fe 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/lib/Sema/SemaExprObjC.cpp @@ -147,7 +147,10 @@ Sema::ExprResult Sema::ActOnClassMessage( Expr **ArgExprs = reinterpret_cast<Expr **>(Args); ObjCInterfaceDecl* ClassDecl = 0; + bool isSuper = false; + if (!strcmp(receiverName->getName(), "super") && getCurMethodDecl()) { + isSuper = true; ClassDecl = getCurMethodDecl()->getClassInterface()->getSuperClass(); if (!ClassDecl) return Diag(lbrac, diag::error_no_super_class, @@ -206,11 +209,14 @@ Sema::ExprResult Sema::ActOnClassMessage( // If we have the ObjCInterfaceDecl* for the class that is receiving // the message, use that to construct the ObjCMessageExpr. Otherwise // pass on the IdentifierInfo* for the class. - if (ClassDecl) - return new ObjCMessageExpr(ClassDecl, Sel, returnType, Method, + // FIXME: need to do a better job handling 'super' usage within a class + // For now, we simply pass the "super" identifier through (which isn't + // consistent with instance methods. + if (isSuper || !ClassDecl) + return new ObjCMessageExpr(receiverName, Sel, returnType, Method, lbrac, rbrac, ArgExprs, NumArgs); else - return new ObjCMessageExpr(receiverName, Sel, returnType, Method, + return new ObjCMessageExpr(ClassDecl, Sel, returnType, Method, lbrac, rbrac, ArgExprs, NumArgs); } |