summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGObjC.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2012-08-20 23:36:59 +0000
committerJohn McCall <rjmccall@apple.com>2012-08-20 23:36:59 +0000
commitd8561f058d8c3497dd7a98dbffcd30b0d4be22b0 (patch)
tree925017d0a36bc904ebda2d8464c26e1e2bb5395a /clang/lib/CodeGen/CGObjC.cpp
parent4a903df403f360482068b05cb20b6ef47b7d68eb (diff)
downloadbcm5719-llvm-d8561f058d8c3497dd7a98dbffcd30b0d4be22b0.tar.gz
bcm5719-llvm-d8561f058d8c3497dd7a98dbffcd30b0d4be22b0.zip
Fix a pair of bugs relating to properties in ARC.
First, when synthesizing an explicitly strong/retain/copy property of Class type, don't pretend during compatibility checking that the property is actually assign. Instead, resolve incompatibilities by secretly changing the type of *implicitly* __unsafe_unretained Class ivars to be strong. This is moderately evil but better than what we were doing. Second, when synthesizing the setter for a strong property of non-retainable type, be sure to use objc_setProperty. This is possible when the property is decorated with the NSObject attribute. This is an ugly, ugly corner of the language, and we probably ought to deprecate it. The first is rdar://problem/12039404; the second was noticed by inspection while fixing the first. llvm-svn: 162244
Diffstat (limited to 'clang/lib/CodeGen/CGObjC.cpp')
-rw-r--r--clang/lib/CodeGen/CGObjC.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index 4ac172d1cbb..e0762846dc1 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -613,7 +613,16 @@ PropertyImplStrategy::PropertyImplStrategy(CodeGenModule &CGM,
// which translates to objc_storeStrong. This isn't required, but
// it's slightly nicer.
} else if (CGM.getLangOpts().ObjCAutoRefCount && !IsAtomic) {
- Kind = Expression;
+ // Using standard expression emission for the setter is only
+ // acceptable if the ivar is __strong, which won't be true if
+ // the property is annotated with __attribute__((NSObject)).
+ // TODO: falling all the way back to objc_setProperty here is
+ // just laziness, though; we could still use objc_storeStrong
+ // if we hacked it right.
+ if (ivarType.getObjCLifetime() == Qualifiers::OCL_Strong)
+ Kind = Expression;
+ else
+ Kind = SetPropertyAndExpressionGet;
return;
// Otherwise, we need to at least use setProperty. However, if
OpenPOWER on IntegriCloud