[cfe-commits] r44148 - /cfe/trunk/Driver/RewriteTest.cpp

Steve Naroff snaroff at apple.com
Wed Nov 14 15:54:14 PST 2007


Author: snaroff
Date: Wed Nov 14 17:54:14 2007
New Revision: 44148

URL: http://llvm.org/viewvc/llvm-project?rev=44148&view=rev
Log:

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...

Modified:
    cfe/trunk/Driver/RewriteTest.cpp

Modified: cfe/trunk/Driver/RewriteTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteTest.cpp?rev=44148&r1=44147&r2=44148&view=diff

==============================================================================
--- cfe/trunk/Driver/RewriteTest.cpp (original)
+++ cfe/trunk/Driver/RewriteTest.cpp Wed Nov 14 17:54:14 2007
@@ -1043,9 +1043,17 @@
     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 @@
   
   // 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);





More information about the cfe-commits mailing list