aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-09-08 19:45:47 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-09-08 19:45:47 +0000
commitac423ba85bb59cc7cc1d43081b20d7e8d40355ff (patch)
tree43f3e6563d517b2f5ba87753c2541548b77963cd
parent60e818811a419686fe9e998d169ac21858366ebf (diff)
Fixes a regression in generating objc's GC API
in assiging to c pointer types with a GC'able attribute. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81244 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/Type.h3
-rw-r--r--test/CodeGenObjC/objc2-strong-cast-4.m23
2 files changed, 26 insertions, 0 deletions
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index f46227d85f..4cebdcdf21 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -2235,6 +2235,9 @@ inline QualType::GCAttrTypes QualType::getObjCGCAttr() const {
return EXTQT->getObjCGCAttr();
if (const ObjCObjectPointerType *PT = CT->getAsObjCObjectPointerType())
return PT->getPointeeType().getObjCGCAttr();
+ // We most look at all pointer types, not just pointer to interface types.
+ if (const PointerType *PT = CT->getAs<PointerType>())
+ return PT->getPointeeType().getObjCGCAttr();
return GCNone;
}
diff --git a/test/CodeGenObjC/objc2-strong-cast-4.m b/test/CodeGenObjC/objc2-strong-cast-4.m
new file mode 100644
index 0000000000..e351f48477
--- /dev/null
+++ b/test/CodeGenObjC/objc2-strong-cast-4.m
@@ -0,0 +1,23 @@
+// RUN: clang-cc -triple x86_64-apple-darwin10 -fobjc-gc -emit-llvm -o %t %s &&
+// RUN: grep objc_assign_strongCast %t | count 3 &&
+// RUN: true
+
+struct Slice {
+ void *__strong * items;
+};
+
+typedef struct Slice Slice;
+
+@interface ISlice {
+@public
+ void *__strong * items;
+}
+@end
+
+void foo () {
+ Slice *slice;
+ slice->items = 0;
+
+ ISlice *islice;
+ islice->items = 0;
+}