aboutsummaryrefslogtreecommitdiff
path: root/Driver/RewriteTest.cpp
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2007-11-14 23:54:14 +0000
committerSteve Naroff <snaroff@apple.com>2007-11-14 23:54:14 +0000
commit6568d4dd760f37a945f7c9a249b1500de0777a2d (patch)
tree876a4890ecf04bc94665c466ca2370ee5ce944af /Driver/RewriteTest.cpp
parent049b1684bb7d7177a89da36c347bd33b4a1c6ef2 (diff)
Cast implicit "self" argument to "id". This removes all warnings associated with implicit references to self. It doesn't yet deal withexplicit references to self...
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44148 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/RewriteTest.cpp')
-rw-r--r--Driver/RewriteTest.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/Driver/RewriteTest.cpp b/Driver/RewriteTest.cpp
index 286b493ddb..c5c851b4ec 100644
--- a/Driver/RewriteTest.cpp
+++ b/Driver/RewriteTest.cpp
@@ -1043,9 +1043,17 @@ Stmt *RewriteTest::RewriteMessageExpr(ObjCMessageExpr *Exp) {
CallExpr *Cls = SynthesizeCallToFunctionDecl(GetClassFunctionDecl,
&ClsExprs[0], ClsExprs.size());
MsgExprs.push_back(Cls);
- } else // instance message.
- MsgExprs.push_back(Exp->getReceiver());
+ } else { // instance message.
+ Expr *recExpr = Exp->getReceiver();
+ // Make sure we cast "self" to "id".
+ if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(recExpr)) {
+ if (!strcmp(DRE->getDecl()->getName(), "self"))
+ recExpr = new CastExpr(Context->getObjcIdType(), recExpr,
+ SourceLocation());
+ }
+ MsgExprs.push_back(recExpr);
+ }
// Create a call to sel_registerName("selName"), it will be the 2nd argument.
llvm::SmallVector<Expr*, 8> SelExprs;
QualType argType = Context->getPointerType(Context->CharTy);
@@ -1059,7 +1067,16 @@ Stmt *RewriteTest::RewriteMessageExpr(ObjCMessageExpr *Exp) {
// Now push any user supplied arguments.
for (unsigned i = 0; i < Exp->getNumArgs(); i++) {
- MsgExprs.push_back(Exp->getArg(i));
+ Expr *userExpr = Exp->getArg(i);
+#if 0
+ // Make sure we cast "self" to "id".
+ if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(userExpr)) {
+ if (!strcmp(DRE->getDecl()->getName(), "self"))
+ userExpr = new CastExpr(Context->getObjcIdType(), userExpr,
+ SourceLocation());
+ }
+#endif
+ MsgExprs.push_back(userExpr);
// We've transferred the ownership to MsgExprs. Null out the argument in
// the original expression, since we will delete it below.
Exp->setArg(i, 0);