]> granicus.if.org Git - clang/commitdiff
Fix rewriter to match recent changes in property ref
authorFariborz Jahanian <fjahanian@apple.com>
Sat, 4 Dec 2010 21:22:13 +0000 (21:22 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Sat, 4 Dec 2010 21:22:13 +0000 (21:22 +0000)
AST.

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

lib/Rewrite/RewriteObjC.cpp
test/Rewriter/properties.m
test/Rewriter/rewrite-nested-property-in-blocks.mm

index 286ac0f63810a1129037ec18230c72191393b44e..d689f22f68d7a4e13b3be19a49c819d6b2126352 100644 (file)
@@ -1361,12 +1361,20 @@ Stmt *RewriteObjC::RewritePropertyOrImplicitGetter(Expr *PropOrGetterRefExpr) {
 
   if (!PropParentMap)
     PropParentMap = new ParentMap(CurrentBody);
-
+  bool NestedPropertyRef = false;
   Stmt *Parent = PropParentMap->getParent(PropOrGetterRefExpr);
-  if (Parent && isa<ObjCPropertyRefExpr>(Parent)) {
+  ImplicitCastExpr*ICE=0;
+  if (Parent)
+    if ((ICE = dyn_cast<ImplicitCastExpr>(Parent))) {
+      assert((ICE->getCastKind() == CK_GetObjCProperty)
+             && "RewritePropertyOrImplicitGetter");
+      Parent = PropParentMap->getParent(Parent);
+      NestedPropertyRef = (Parent && isa<ObjCPropertyRefExpr>(Parent));
+    }
+  if (NestedPropertyRef) {
     // We stash away the ReplacingStmt since actually doing the
     // replacement/rewrite won't work for nested getters (e.g. obj.p.i)
-    PropGetters[PropOrGetterRefExpr] = ReplacingStmt;
+    PropGetters[ICE] = ReplacingStmt;
     // NOTE: We don't want to call MsgExpr->Destroy(), as it holds references
     // to things that stay around.
     Context->Deallocate(MsgExpr);
index bfc8dc124b9c651525396575742cefe1b124e261..89177d7e64b5c4cd9426e3ea800a702fd94476e3 100644 (file)
@@ -1,9 +1,7 @@
-// RUN: %clang_cc1 -rewrite-objc %s -o -
+// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -fms-extensions -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
 
-// Fariborz approved this being xfail'ed during the addition
-// of explicit lvalue-to-rvalue conversions.
-// RUN: false
-// XFAIL: *
+void *sel_registerName(const char *);
 
 @interface Foo {
     int i;
index 348858ccc1d9f77f40ffce4eb675aaa18848ce25..2dffe66ab326bf6f1af82e7f01a6df02a818e7e1 100755 (executable)
@@ -2,10 +2,6 @@
 // RUN: %clang_cc1 -fsyntax-only -fms-extensions -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
 // radar 8608293
 
-// Fariborz approved this being xfail'ed during the addition
-// of explicit lvalue-to-rvalue conversions.
-// XFAIL: *
-
 void *sel_registerName(const char *);
 
 extern "C" void nowarn(id);