Fixup rewrite of ivars accessed via an explicit object

in a function. Fixes radar 7522803.

llvm-svn: 93159
This commit is contained in:
Fariborz Jahanian 2010-01-11 17:50:35 +00:00
parent 3a55686345
commit 9146e44124
2 changed files with 9 additions and 3 deletions

View 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(),

View 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 {
@ -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];