]> granicus.if.org Git - clang/commitdiff
Fixup rewrite of ivars accessed via an explicit object
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 11 Jan 2010 17:50:35 +0000 (17:50 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 11 Jan 2010 17:50:35 +0000 (17:50 +0000)
in a function. Fixes radar 7522803.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93159 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/RewriteObjC.cpp
test/Rewriter/rewrite-ivar-use.m

index 3000d7760554cd25334e2264e0728a3f85a85aad..28f79aa10adfcbcc641312d8b319dd75b78d7cae 100644 (file)
@@ -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(),
index 9d6a0fa6bb80fb42238670ca11e632ee2de1ccd9..82cff5b2d6335962eb3af87dcc3eed88e0b5876b 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -rewrite-objc -fms-extensions %s -o -
 // radar 7490331
 
 @interface Foo {
 @end
 
 @implementation Foo
+// radar 7522803
+static void foo(id bar) {
+        int i = ((Foo *)bar)->a;
+}
+
 - (void)bar {
         a = 42;
         [self baz:b];