[cfe-commits] r53994 - in /cfe/trunk: Driver/RewriteObjC.cpp include/clang/AST/ExprObjC.h lib/Sema/SemaExprObjC.cpp
Steve Naroff
snaroff at apple.com
Thu Jul 24 12:44:34 PDT 2008
Author: snaroff
Date: Thu Jul 24 14:44:33 2008
New Revision: 53994
URL: http://llvm.org/viewvc/llvm-project?rev=53994&view=rev
Log:
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).
Modified:
cfe/trunk/Driver/RewriteObjC.cpp
cfe/trunk/include/clang/AST/ExprObjC.h
cfe/trunk/lib/Sema/SemaExprObjC.cpp
Modified: cfe/trunk/Driver/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteObjC.cpp?rev=53994&r1=53993&r2=53994&view=diff
==============================================================================
--- cfe/trunk/Driver/RewriteObjC.cpp (original)
+++ cfe/trunk/Driver/RewriteObjC.cpp Thu Jul 24 14:44:33 2008
@@ -2000,6 +2000,8 @@
// Derive/push the receiver/selector, 2 implicit arguments to objc_msgSend().
if (clsName) { // class message.
+ // FIXME: We need to fix Sema (and the AST for ObjCMessageExpr) to handle
+ // the 'super' idiom within a class method.
if (!strcmp(clsName->getName(), "super")) {
MsgSendFlavor = MsgSendSuperFunctionDecl;
if (MsgSendStretFlavor)
Modified: cfe/trunk/include/clang/AST/ExprObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprObjC.h?rev=53994&r1=53993&r2=53994&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprObjC.h (original)
+++ cfe/trunk/include/clang/AST/ExprObjC.h Thu Jul 24 14:44:33 2008
@@ -286,6 +286,7 @@
/// getReceiver - Returns the receiver of the message expression.
/// This can be NULL if the message is for class methods. For
/// class methods, use getClassName.
+ /// FIXME: need to handle/detect 'super' usage within a class method.
Expr *getReceiver() {
uintptr_t x = (uintptr_t) SubExprs[RECEIVER];
return (x & Flags) == IsInstMeth ? (Expr*) x : 0;
Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=53994&r1=53993&r2=53994&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Thu Jul 24 14:44:33 2008
@@ -147,7 +147,10 @@
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 @@
// 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);
}
More information about the cfe-commits
mailing list