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

Steve Naroff snaroff at apple.com
Thu Nov 15 03:33:06 PST 2007


Author: snaroff
Date: Thu Nov 15 05:33:00 2007
New Revision: 44170

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

Extend RewriteTest::RewriteObjCIvarRefExpr() to cope with static typing (when using -> on a type which corresponds to the implementation type).


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=44170&r1=44169&r2=44170&view=diff

==============================================================================
--- cfe/trunk/Driver/RewriteTest.cpp (original)
+++ cfe/trunk/Driver/RewriteTest.cpp Thu Nov 15 05:33:00 2007
@@ -594,9 +594,27 @@
     Rewrite.ReplaceStmt(IV, Replacement);
     delete IV;
     return Replacement;
-  }
-  else
+  } else {
+    if (CurMethodDecl) {
+      if (const PointerType *pType = IV->getBase()->getType()->getAsPointerType()) {
+        ObjcInterfaceType *intT = dyn_cast<ObjcInterfaceType>(pType->getPointeeType());
+        if (CurMethodDecl->getClassInterface() == intT->getDecl()) {
+          IdentifierInfo *II = intT->getDecl()->getIdentifier();
+          RecordDecl *RD = new RecordDecl(Decl::Struct, SourceLocation(),
+                                          II, 0);
+          QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
+          
+          CastExpr *castExpr = new CastExpr(castT, IV->getBase(), SourceLocation());
+          // Don't forget the parens to enforce the proper binding.
+          ParenExpr *PE = new ParenExpr(SourceLocation(), SourceLocation(), castExpr);
+          Rewrite.ReplaceStmt(IV->getBase(), PE);
+          delete IV->getBase();
+          return PE;
+        }
+      }
+    }
     return IV;
+  }
 }
 
 //===----------------------------------------------------------------------===//





More information about the cfe-commits mailing list