summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2010-01-11 17:50:35 +0000
committerFariborz Jahanian <fjahanian@apple.com>2010-01-11 17:50:35 +0000
commit9146e44124907679d2b568098a0f922cf93cb3e5 (patch)
treed26aa2d14e41442db51909d0fcdb072d87795939
parent3a556863451292513d206083943210f7ef450677 (diff)
downloadbcm5719-llvm-9146e44124907679d2b568098a0f922cf93cb3e5.tar.gz
bcm5719-llvm-9146e44124907679d2b568098a0f922cf93cb3e5.zip
Fixup rewrite of ivars accessed via an explicit object
in a function. Fixes radar 7522803. llvm-svn: 93159
-rw-r--r--clang/lib/Frontend/RewriteObjC.cpp5
-rw-r--r--clang/test/Rewriter/rewrite-ivar-use.m7
2 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/Frontend/RewriteObjC.cpp b/clang/lib/Frontend/RewriteObjC.cpp
index 3000d776055..28f79aa10ad 100644
--- a/clang/lib/Frontend/RewriteObjC.cpp
+++ b/clang/lib/Frontend/RewriteObjC.cpp
@@ -1235,8 +1235,9 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
// Explicit ivar refs need to have a cast inserted.
// FIXME: consider sharing some of this code with the code above.
- if (const PointerType *pType = IV->getBase()->getType()->getAs<PointerType>()) {
- ObjCInterfaceType *iFaceDecl = dyn_cast<ObjCInterfaceType>(pType->getPointeeType());
+ if (IV->isArrow()) {
+ ObjCInterfaceType *iFaceDecl =
+ dyn_cast<ObjCInterfaceType>(BaseExpr->getType()->getPointeeType());
// lookup which class implements the instance variable.
ObjCInterfaceDecl *clsDeclared = 0;
iFaceDecl->getDecl()->lookupInstanceVariable(D->getIdentifier(),
diff --git a/clang/test/Rewriter/rewrite-ivar-use.m b/clang/test/Rewriter/rewrite-ivar-use.m
index 9d6a0fa6bb8..82cff5b2d63 100644
--- a/clang/test/Rewriter/rewrite-ivar-use.m
+++ b/clang/test/Rewriter/rewrite-ivar-use.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fms-extensions %s -o -
// radar 7490331
@interface Foo {
@@ -10,6 +10,11 @@
@end
@implementation Foo
+// radar 7522803
+static void foo(id bar) {
+ int i = ((Foo *)bar)->a;
+}
+
- (void)bar {
a = 42;
[self baz:b];
OpenPOWER on IntegriCloud