aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-09-10 23:38:45 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-09-10 23:38:45 +0000
commit75212ee91313bc1b6dd826d9b173541bc4016539 (patch)
tree23f58a22a975567ea93121de6cac3b59e31abf28
parentf299124fe491879fed48f611f6f299382d114dd4 (diff)
Fix a regression where write-barrier was not being generated
for block pointer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81479 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/AST/ASTContext.cpp2
-rw-r--r--test/CodeGenObjC/objc2-strong-cast-4.m13
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index bf1fac9eec..84a5195a60 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -3391,7 +3391,7 @@ QualType::GCAttrTypes ASTContext::getObjCGCAttrKind(const QualType &Ty) const {
// (or pointers to them) be treated as though they were declared
// as __strong.
if (GCAttrs == QualType::GCNone) {
- if (Ty->isObjCObjectPointerType())
+ if (Ty->isObjCObjectPointerType() || Ty->isBlockPointerType())
GCAttrs = QualType::Strong;
else if (Ty->isPointerType())
return getObjCGCAttrKind(Ty->getAs<PointerType>()->getPointeeType());
diff --git a/test/CodeGenObjC/objc2-strong-cast-4.m b/test/CodeGenObjC/objc2-strong-cast-4.m
index 350b2b0bed..6603e32465 100644
--- a/test/CodeGenObjC/objc2-strong-cast-4.m
+++ b/test/CodeGenObjC/objc2-strong-cast-4.m
@@ -1,5 +1,5 @@
// RUN: clang-cc -triple x86_64-apple-darwin10 -fobjc-gc -emit-llvm -o %t %s &&
-// RUN: grep objc_assign_strongCast %t | count 7 &&
+// RUN: grep objc_assign_strongCast %t | count 8 &&
// RUN: true
struct Slice {
@@ -14,6 +14,14 @@ typedef struct Slice Slice;
}
@end
+typedef void (^observer_block_t)(id object);
+@interface Observer {
+@public
+ observer_block_t block;
+}
+@end
+
+
void foo (int i) {
// storing into an array of strong pointer types.
void *__strong* items;
@@ -32,4 +40,7 @@ void foo (int i) {
islice->IvarItem = 0;
// Storing into an ivar of an array of strong pointer types.
islice->IvarItem[i] = (void*)0;
+
+ Observer *observer;
+ observer->block = 0;
}