From 9f0e310861359c78f4dbaed358c599c91959cad6 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Tue, 18 Dec 2007 21:33:44 +0000 Subject: Refactoring work. ObjcQualifiedIdType is now derived from 'Type'. llvm-svn: 45174 --- clang/Driver/RewriteTest.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'clang/Driver/RewriteTest.cpp') diff --git a/clang/Driver/RewriteTest.cpp b/clang/Driver/RewriteTest.cpp index 30b1e98af07..cb839ba2bda 100644 --- a/clang/Driver/RewriteTest.cpp +++ b/clang/Driver/RewriteTest.cpp @@ -490,7 +490,7 @@ void RewriteTest::RewriteForwardProtocolDecl(ObjcForwardProtocolDecl *PDecl) { void RewriteTest::RewriteObjcMethodDecl(ObjcMethodDecl *OMD, std::string &ResultStr) { ResultStr += "\nstatic "; - if (isa(OMD->getResultType())) + if (OMD->getResultType()->isObjcQualifiedIdType()) ResultStr += "id"; else ResultStr += OMD->getResultType().getAsString(); @@ -551,7 +551,7 @@ void RewriteTest::RewriteObjcMethodDecl(ObjcMethodDecl *OMD, for (int i = 0; i < OMD->getNumParams(); i++) { ParmVarDecl *PDecl = OMD->getParamDecl(i); ResultStr += ", "; - if (isa(PDecl->getType())) + if (PDecl->getType()->isObjcQualifiedIdType()) ResultStr += "id"; else ResultStr += PDecl->getType().getAsString(); @@ -999,7 +999,7 @@ bool RewriteTest::needToScanForQualifiers(QualType T) { if (T == Context->getObjcIdType()) return true; - if (isa(T)) + if (T->isObjcQualifiedIdType()) return true; if (const PointerType *pType = T->getAsPointerType()) { @@ -1321,7 +1321,7 @@ ObjcInterfaceDecl *RewriteTest::isSuperReceiver(Expr *recExpr) { if (ParmVarDecl *PVD = dyn_cast(DRE->getDecl())) { if (!strcmp(PVD->getName(), "self")) { // is this id type? - if (isa(CE->getType())) + if (CE->getType()->isObjcQualifiedIdType()) return 0; if (const PointerType *PT = CE->getType()->getAsPointerType()) { if (ObjcInterfaceType *IT = @@ -1516,9 +1516,18 @@ Stmt *RewriteTest::RewriteMessageExpr(ObjCMessageExpr *Exp) { // Make all implicit casts explicit...ICE comes in handy:-) if (ImplicitCastExpr *ICE = dyn_cast(userExpr)) { // Reuse the ICE type, it is exactly what the doctor ordered. - userExpr = new CastExpr(isa(ICE->getType()) + userExpr = new CastExpr(ICE->getType()->isObjcQualifiedIdType() ? Context->getObjcIdType() : ICE->getType(), userExpr, SourceLocation()); + } + // Make id cast into an 'id' cast. + else if (CastExpr *CE = dyn_cast(userExpr)) { + if (CE->getType()->isObjcQualifiedIdType()) { + while ((CE = dyn_cast(userExpr))) + userExpr = CE->getSubExpr(); + userExpr = new CastExpr(Context->getObjcIdType(), + userExpr, SourceLocation()); + } } MsgExprs.push_back(userExpr); // We've transferred the ownership to MsgExprs. Null out the argument in @@ -1539,12 +1548,12 @@ Stmt *RewriteTest::RewriteMessageExpr(ObjCMessageExpr *Exp) { if (ObjcMethodDecl *mDecl = Exp->getMethodDecl()) { // Push any user argument types. for (int i = 0; i < mDecl->getNumParams(); i++) { - QualType t = isa(mDecl->getParamDecl(i)->getType()) + QualType t = mDecl->getParamDecl(i)->getType()->isObjcQualifiedIdType() ? Context->getObjcIdType() : mDecl->getParamDecl(i)->getType(); ArgTypes.push_back(t); } - returnType = isa(mDecl->getResultType()) + returnType = mDecl->getResultType()->isObjcQualifiedIdType() ? Context->getObjcIdType() : mDecl->getResultType(); } else { returnType = Context->getObjcIdType(); -- cgit v1.2.3