summaryrefslogtreecommitdiffstats
path: root/clang/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
commite7f181986afe91017cf9a7b9de7b8680a0856b85 (patch)
tree28d8fffbeec23c15d55556d531e624f1ba698237 /clang/Driver/RewriteTest.cpp
parentcf7a20a6c4ba0f3bcd9f9174f431820fd332e45f (diff)
downloadbcm5719-llvm-e7f181986afe91017cf9a7b9de7b8680a0856b85.tar.gz
bcm5719-llvm-e7f181986afe91017cf9a7b9de7b8680a0856b85.zip
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...
llvm-svn: 44148
Diffstat (limited to 'clang/Driver/RewriteTest.cpp')
-rw-r--r--clang/Driver/RewriteTest.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/clang/Driver/RewriteTest.cpp b/clang/Driver/RewriteTest.cpp
index 286b493ddb3..c5c851b4ec0 100644
--- a/clang/Driver/RewriteTest.cpp
+++ b/clang/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);
OpenPOWER on IntegriCloud