diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-05-23 02:49:02 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-05-23 02:49:02 +0000 |
commit | e226534b06dc18a50deae0a1b5221984e7911137 (patch) | |
tree | f848710d0151242f75329c0c952392eba062d9cd | |
parent | bf22be630e3d45c5c9c37bacb6325e16314431a6 (diff) |
Initialize Obj-C GC attributes when emitting BlockDeclRefExprs.
- Otherwise we may incorrectly miss generation of some write barriers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72313 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CGExpr.cpp | 4 | ||||
-rw-r--r-- | test/CodeGenObjC/blocks-2.m | 11 |
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 0b7ad05b30..2fe6754293 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -723,7 +723,9 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { } LValue CodeGenFunction::EmitBlockDeclRefLValue(const BlockDeclRefExpr *E) { - return LValue::MakeAddr(GetAddrOfBlockDecl(E), 0); + return LValue::MakeAddr(GetAddrOfBlockDecl(E), + E->getType().getCVRQualifiers(), + getContext().getObjCGCAttrKind(E->getType())); } LValue CodeGenFunction::EmitUnaryOpLValue(const UnaryOperator *E) { diff --git a/test/CodeGenObjC/blocks-2.m b/test/CodeGenObjC/blocks-2.m new file mode 100644 index 0000000000..a4d8bfa6b7 --- /dev/null +++ b/test/CodeGenObjC/blocks-2.m @@ -0,0 +1,11 @@ +// RUN: clang-cc %s -emit-llvm -o %t -fobjc-gc -fblocks -triple i386-apple-darwin10 && +// RUN: grep "objc_assign_strongCast" %t | count 2 && +// RUN: true + +// This should generate a strong cast. + +id test3(id x) { + __block id result; + ^{ result = x; }(); + return result; +} |