aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-06-03 17:15:17 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-06-03 17:15:17 +0000
commit4027cd1b924e29784a49085b1717f35cdd719146 (patch)
treee9152a6cca9ffe892fe479178a8fccaab38d2ca3
parente5280286573d4fe1220cdd66e147b572a05536a8 (diff)
Place the GC attribute on the same relative pointer
position to make it consistant and to match gcc's behavior, by placing it at the inner-most pointer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72784 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/AST/ASTContext.cpp7
-rw-r--r--test/CodeGenObjC/objc2-weak-assign.m22
2 files changed, 29 insertions, 0 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 3b405267e8..b36d1f3dbf 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -828,6 +828,13 @@ QualType ASTContext::getObjCGCQualType(QualType T,
if (CanT.getObjCGCAttr() == GCAttr)
return T;
+ if (T->isPointerType()) {
+ QualType Pointee = T->getAsPointerType()->getPointeeType();
+ if (Pointee->isPointerType()) {
+ QualType ResultType = getObjCGCQualType(Pointee, GCAttr);
+ return getPointerType(ResultType);
+ }
+ }
// If we are composing extended qualifiers together, merge together into one
// ExtQualType node.
unsigned CVRQuals = T.getCVRQualifiers();
diff --git a/test/CodeGenObjC/objc2-weak-assign.m b/test/CodeGenObjC/objc2-weak-assign.m
new file mode 100644
index 0000000000..a3740b207e
--- /dev/null
+++ b/test/CodeGenObjC/objc2-weak-assign.m
@@ -0,0 +1,22 @@
+// RUN: clang-cc -triple x86_64-apple-darwin9 -fobjc-gc -emit-llvm -o %t %s &&
+// RUN: grep -e "objc_assign_weak" %t | grep -e "call" | count 6
+
+__weak id* x;
+id* __weak y;
+id* __weak* z;
+
+__weak id* a1[20];
+id* __weak a2[30];
+id** __weak a3[40];
+
+int main()
+{
+ *x = 0;
+ *y = 0;
+ **z = 0;
+
+ a1[3] = 0;
+ a2[3] = 0;
+ a3[3][4] = 0;
+}
+