aboutsummaryrefslogtreecommitdiff
path: root/Driver/RewriteTest.cpp
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2007-11-15 11:33:00 +0000
committerSteve Naroff <snaroff@apple.com>2007-11-15 11:33:00 +0000
commitc2a689b0bd0cda7bc1522dc0057f01f0897e6d3d (patch)
treef88e7a907ec2781d10c86251bda6a1e2d95bc2c9 /Driver/RewriteTest.cpp
parentc3a438c39ca6061965007c273727f27dfaa4a694 (diff)
Extend RewriteTest::RewriteObjCIvarRefExpr() to cope with static typing (when using -> on a type which corresponds to the implementation type).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44170 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/RewriteTest.cpp')
-rw-r--r--Driver/RewriteTest.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/Driver/RewriteTest.cpp b/Driver/RewriteTest.cpp
index 5dc36923fc..a768d17b3a 100644
--- a/Driver/RewriteTest.cpp
+++ b/Driver/RewriteTest.cpp
@@ -594,9 +594,27 @@ Stmt *RewriteTest::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
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;
+ }
}
//===----------------------------------------------------------------------===//