[cfe-commits] r43704 - /cfe/trunk/Driver/RewriteTest.cpp
Steve Naroff
snaroff at apple.com
Mon Nov 5 06:36:38 PST 2007
Author: snaroff
Date: Mon Nov 5 08:36:37 2007
New Revision: 43704
URL: http://llvm.org/viewvc/llvm-project?rev=43704&view=rev
Log:
- change the synthesized typedef (for classes) to be of type "objc_object".
- fix a couple bugs in RewriteObjCStringLiteral.
- convert "Class" -> "id" in RewriteMessageExpr.
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=43704&r1=43703&r2=43704&view=diff
==============================================================================
--- cfe/trunk/Driver/RewriteTest.cpp (original)
+++ cfe/trunk/Driver/RewriteTest.cpp Mon Nov 5 08:36:37 2007
@@ -273,9 +273,7 @@
ObjcInterfaceDecl *ForwardDecl = ForwardDecls[i];
if (ObjcForwardDecls.count(ForwardDecl))
continue;
- typedefString += "typedef struct ";
- typedefString += ForwardDecl->getName();
- typedefString += " ";
+ typedefString += "typedef struct objc_object ";
typedefString += ForwardDecl->getName();
typedefString += ";\n";
@@ -341,9 +339,7 @@
std::string ResultStr;
if (!ObjcForwardDecls.count(ClassDecl)) {
// we haven't seen a forward decl - generate a typedef.
- ResultStr += "typedef struct ";
- ResultStr += ClassDecl->getName();
- ResultStr += " ";
+ ResultStr += "typedef struct objc_object ";
ResultStr += ClassDecl->getName();
ResultStr += ";";
@@ -586,15 +582,11 @@
expType = Context->getPointerType(StrRep->getType());
Unop = new UnaryOperator(StrRep, UnaryOperator::AddrOf, expType,
SourceLocation());
- // struct NSString *
- if (!NSStringRecord)
- NSStringRecord = new RecordDecl(Decl::Struct, SourceLocation(),
- &Context->Idents.get("NSString"), 0);
- expType = Context->getPointerType(Context->getTagDeclType(NSStringRecord));
- cast = new CastExpr(expType, Unop, SourceLocation());
+ // cast to NSConstantString *
+ cast = new CastExpr(Exp->getType(), Unop, SourceLocation());
Rewrite.ReplaceStmt(Exp, cast);
delete Exp;
- return StrRep;
+ return cast;
}
Stmt *RewriteTest::RewriteMessageExpr(ObjCMessageExpr *Exp) {
@@ -650,8 +642,12 @@
ArgTypes.push_back(Context->getObjcSelType());
if (ObjcMethodDecl *mDecl = Exp->getMethodDecl()) {
// Push any user argument types.
- for (int i = 0; i < mDecl->getNumParams(); i++)
- ArgTypes.push_back(mDecl->getParamDecl(i)->getType());
+ for (int i = 0; i < mDecl->getNumParams(); i++) {
+ QualType t = mDecl->getParamDecl(i)->getType();
+ if (t == Context->getObjcClassType())
+ t = Context->getObjcIdType(); // Convert "Class"->"id"
+ ArgTypes.push_back(t);
+ }
returnType = mDecl->getResultType();
} else {
returnType = Context->getObjcIdType();
More information about the cfe-commits
mailing list