Fixup codegen for write barriers for block variables. Radar 6786715

llvm-svn: 69642
This commit is contained in:
Mike Stump 2009-04-21 00:51:43 +00:00
parent be9dae80b3
commit 3214d12325
4 changed files with 22 additions and 11 deletions

View File

@ -2009,7 +2009,7 @@ inline bool Type::isPointerType() const {
return isa<PointerType>(CanonicalType.getUnqualifiedType());
}
inline bool Type::isBlockPointerType() const {
return isa<BlockPointerType>(CanonicalType);
return isa<BlockPointerType>(CanonicalType.getUnqualifiedType());
}
inline bool Type::isReferenceType() const {
return isa<ReferenceType>(CanonicalType.getUnqualifiedType());

View File

@ -561,7 +561,10 @@ struct DeclaratorChunk {
/// For now, sema will catch these as invalid.
/// The type qualifiers: const/volatile/restrict.
unsigned TypeQuals : 3;
void destroy() {}
AttributeList *AttrList;
void destroy() {
delete AttrList;
}
};
struct MemberPointerTypeInfo {
@ -617,7 +620,7 @@ struct DeclaratorChunk {
case MemberPointer: return Mem.AttrList;
case Array: return 0;
case Function: return 0;
case BlockPointer: return 0; // FIXME: Do blocks have attr list?
case BlockPointer: return Cls.AttrList;
}
}
@ -672,12 +675,13 @@ struct DeclaratorChunk {
/// getBlockPointer - Return a DeclaratorChunk for a block.
///
static DeclaratorChunk getBlockPointer(unsigned TypeQuals,
SourceLocation Loc) {
static DeclaratorChunk getBlockPointer(unsigned TypeQuals, SourceLocation Loc,
AttributeList *AL) {
DeclaratorChunk I;
I.Kind = BlockPointer;
I.Loc = Loc;
I.Cls.TypeQuals = TypeQuals;
I.Cls.AttrList = AL;
return I;
}

View File

@ -1876,7 +1876,7 @@ void Parser::ParseDeclaratorInternal(Declarator &D,
else
// Remember that we parsed a Block type, and remember the type-quals.
D.AddTypeInfo(DeclaratorChunk::getBlockPointer(DS.getTypeQualifiers(),
Loc),
Loc, DS.TakeAttributes()),
SourceLocation());
} else {
// Is a reference

View File

@ -1,13 +1,13 @@
// RUN: clang-cc %s -emit-llvm -o %t -fobjc-gc -fblocks -triple i386-apple-darwin10 &&
// RUN: grep "_Block_object_dispose" %t | count 4 &&
// RUN: grep "__copy_helper_block_" %t | count 2 &&
// RUN: grep "__destroy_helper_block_" %t | count 2 &&
// RUN: grep "_Block_object_dispose" %t | count 6 &&
// RUN: grep "__copy_helper_block_" %t | count 4 &&
// RUN: grep "__destroy_helper_block_" %t | count 4 &&
// 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 0 &&
// RUN: grep "_Block_object_assign" %t | count 3 &&
// RUN: grep "_Block_object_assign" %t | count 4 &&
// RUN: grep "objc_read_weak" %t | count 2 &&
// RUN: grep "objc_assign_weak" %t | count 2
// RUN: grep "objc_assign_weak" %t | count 3
@interface NSDictionary @end
@ -24,3 +24,10 @@ void foo() {
l = weakSelf;
weakSelf = l;
}
void (^__weak b)(void);
void test2() {
__block int i = 0;
b = ^ { ++i; };
}