From 6568d4dd760f37a945f7c9a249b1500de0777a2d Mon Sep 17 00:00:00 2001 From: Steve Naroff Date: Wed, 14 Nov 2007 23:54:14 +0000 Subject: [PATCH] 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 --- Driver/RewriteTest.cpp | 23 ++++++++++++++++++++--- 1 file 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(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 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(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); -- 2.40.0