diff options
-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}} |