diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-11-18 22:39:16 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-11-18 22:39:16 +0000 |
commit | a762514563bcbf52a016f7e6b6730cac035ac92c (patch) | |
tree | 8f6af73e13df8dc1f7324d36770651253248b0c2 | |
parent | bce8d4b0abc22c59d8a5d1537df22b0d13f25db8 (diff) |
Fix a bug where write-barriers for assignment through reference
types was not being generated for objc pointers.
// rdar://8681766.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119751 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CGExpr.cpp | 2 | ||||
-rw-r--r-- | test/CodeGenObjCXX/refence-assign-write-barrier.mm | 20 |
2 files changed, 21 insertions, 1 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 6bfafca857..286665da86 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -1198,7 +1198,7 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { V = Builder.CreateLoad(V, "tmp"); LValue LV = MakeAddrLValue(V, E->getType(), Alignment); - if (NonGCable) { + if (NonGCable && !VD->getType()->isReferenceType()) { LV.getQuals().removeObjCGCAttr(); LV.setNonGC(true); } diff --git a/test/CodeGenObjCXX/refence-assign-write-barrier.mm b/test/CodeGenObjCXX/refence-assign-write-barrier.mm new file mode 100644 index 0000000000..b295eb2567 --- /dev/null +++ b/test/CodeGenObjCXX/refence-assign-write-barrier.mm @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s +// rdar://8681766 + +@interface NSArray +- (NSArray*) retain; +- (void) release; +@end + +void NSAssignArray(NSArray*& target, NSArray* newValue) +{ + if (target == newValue) + return; + + NSArray* oldValue = target; + + target = [newValue retain]; + + [oldValue release]; +} +// CHECK: {{call.* @objc_assign_strongCast}} |