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
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index bf1fac9..84a5195 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -3391,7 +3391,7 @@
// (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 350b2b0..6603e32 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 @@
}
@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 @@
islice->IvarItem = 0;
// Storing into an ivar of an array of strong pointer types.
islice->IvarItem[i] = (void*)0;
+
+ Observer *observer;
+ observer->block = 0;
}