[cfe-commits] r83150 - in /cfe/trunk: lib/CodeGen/CGExpr.cpp test/CodeGenObjC/objc2-write-barrier-5.m
Fariborz Jahanian
fjahanian at apple.com
Wed Sep 30 10:10:30 PDT 2009
Author: fjahanian
Date: Wed Sep 30 12:10:29 2009
New Revision: 83150
URL: http://llvm.org/viewvc/llvm-project?rev=83150&view=rev
Log:
<rdar://problem/7263113> Make clang produce gcc's objc_assign_StrongCast as a result of type-cast of an ivar in assignment.
Added:
cfe/trunk/test/CodeGenObjC/objc2-write-barrier-5.m
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=83150&r1=83149&r2=83150&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Wed Sep 30 12:10:29 2009
@@ -719,8 +719,18 @@
}
else if (const UnaryOperator *Exp = dyn_cast<UnaryOperator>(E))
setObjCGCLValueClass(Ctx, Exp->getSubExpr(), LV);
- else if (const ParenExpr *Exp = dyn_cast<ParenExpr>(E))
+ else if (const ParenExpr *Exp = dyn_cast<ParenExpr>(E)) {
setObjCGCLValueClass(Ctx, Exp->getSubExpr(), LV);
+ if (LV.isObjCIvar()) {
+ // If cast is to a structure pointer, follow gcc's behavior and make it
+ // a non-ivar write-barrier.
+ QualType ExpTy = E->getType();
+ if (ExpTy->isPointerType())
+ ExpTy = ExpTy->getAs<PointerType>()->getPointeeType();
+ if (ExpTy->isRecordType())
+ LV.SetObjCIvar(LV, false);
+ }
+ }
else if (const ImplicitCastExpr *Exp = dyn_cast<ImplicitCastExpr>(E))
setObjCGCLValueClass(Ctx, Exp->getSubExpr(), LV);
else if (const CStyleCastExpr *Exp = dyn_cast<CStyleCastExpr>(E))
Added: cfe/trunk/test/CodeGenObjC/objc2-write-barrier-5.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/objc2-write-barrier-5.m?rev=83150&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/objc2-write-barrier-5.m (added)
+++ cfe/trunk/test/CodeGenObjC/objc2-write-barrier-5.m Wed Sep 30 12:10:29 2009
@@ -0,0 +1,27 @@
+// RUN: clang-cc -triple x86_64-apple-darwin10 -fobjc-gc -emit-llvm -o %t %s &&
+// RUN: grep objc_assign_ivar %t | count 0 &&
+// RUN: grep objc_assign_strongCast %t | count 5 &&
+// RUN: true
+
+ at interface TestUnarchiver
+{
+ void *allUnarchivedObjects;
+}
+ at end
+
+ at implementation TestUnarchiver
+
+struct unarchive_list {
+ int ifield;
+ id *list;
+};
+
+- (id)init {
+ (*((struct unarchive_list *)allUnarchivedObjects)).list = 0;
+ ((struct unarchive_list *)allUnarchivedObjects)->list = 0;
+ (**((struct unarchive_list **)allUnarchivedObjects)).list = 0;
+ (*((struct unarchive_list **)allUnarchivedObjects))->list = 0;
+ return 0;
+}
+
+ at end
More information about the cfe-commits
mailing list