if (LocalDeclMap[VD]) {
if (BDRE->isByRef()) {
- // FIXME: For only local, or all byrefs?
NoteForHelper[helpersize].flag = BLOCK_FIELD_IS_BYREF |
// FIXME: Someone double check this.
(VD->getType().isObjCGCWeak() ? BLOCK_FIELD_IS_WEAK : 0);
false, false);
}
if (BDRE->isByRef()) {
+ NoteForHelper[helpersize].flag = BLOCK_FIELD_IS_BYREF |
+ // FIXME: Someone double check this.
+ (VD->getType().isObjCGCWeak() ? BLOCK_FIELD_IS_WEAK : 0);
E = new (getContext())
UnaryOperator(E, UnaryOperator::AddrOf,
getContext().getPointerType(E->getType()),
uint64_t Align = getContext().getDeclAlignInBytes(E->getDecl());
const llvm::Type *PtrStructTy
= llvm::PointerType::get(BuildByRefType(E->getType(), Align), 0);
+ // The block literal will need a copy/destroy helper.
+ BlockHasCopyDispose = true;
Ty = PtrStructTy;
Ty = llvm::PointerType::get(Ty, 0);
V = Builder.CreateBitCast(V, Ty);
// RUN: clang %s -emit-llvm -o %t -fblocks -f__block &&
-// RUN: grep "_Block_object_dispose" %t | count 12 &&
-// RUN: grep "__copy_helper_block_" %t | count 8 &&
-// RUN: grep "__destroy_helper_block_" %t | count 8 &&
+// RUN: grep "_Block_object_dispose" %t | count 15 &&
+// RUN: grep "__copy_helper_block_" %t | count 12 &&
+// RUN: grep "__destroy_helper_block_" %t | count 12 &&
// RUN: grep "__Block_byref_id_object_copy_" %t | count 2 &&
// RUN: grep "__Block_byref_id_object_dispose_" %t | count 2 &&
// RUN: grep "i32 135)" %t | count 2 &&
-// RUN: grep "_Block_object_assign" %t | count 7
+// RUN: grep "_Block_object_assign" %t | count 9
#include <stdio.h>
printf("a is %d, b is %d\n", a, b);
}
-
void test2() {
__block int a;
a=1;
^{ (void)i; }();
}
+void test6() {
+ __block int i;
+ ^{ i=1; }();
+}
+
int main() {
int rv = 0;
test1();