summaryrefslogtreecommitdiff
path: root/lib/Sema/SemaObjCProperty.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2018-09-05 19:02:00 +0000
committerJohn McCall <rjmccall@apple.com>2018-09-05 19:02:00 +0000
commit11fd5cf9fd813938a0d3140fb878851c22d67a65 (patch)
tree7de701cc1fe247a14390da507bda909c33a7e19d /lib/Sema/SemaObjCProperty.cpp
parentf742fbf83201b02b17919a50a645bea3bda96f83 (diff)
downloadclang-11fd5cf9fd813938a0d3140fb878851c22d67a65.tar.gz
Add -Wobjc-property-assign-on-object-type.
This is a warning about using 'assign' instead of 'unsafe_unretained' in Objective-C property declarations. It's off by default because there isn't consensus in the Objective-C steering group that this is the right thing to do, but we're nonetheless okay with adding it because there's a substantial pool of Objective-C programmers who will appreciate the warning. Patch by Alfred Zien! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@341489 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaObjCProperty.cpp')
-rw-r--r--lib/Sema/SemaObjCProperty.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp
index ab7b83c4c3..d000027972 100644
--- a/lib/Sema/SemaObjCProperty.cpp
+++ b/lib/Sema/SemaObjCProperty.cpp
@@ -2557,6 +2557,14 @@ void Sema::CheckObjCPropertyAttributes(Decl *PDecl,
PropertyDecl->setInvalidDecl();
}
+ // Check for assign on object types.
+ if ((Attributes & ObjCDeclSpec::DQ_PR_assign) &&
+ !(Attributes & ObjCDeclSpec::DQ_PR_unsafe_unretained) &&
+ PropertyTy->isObjCRetainableType() &&
+ !PropertyTy->isObjCARCImplicitlyUnretainedType()) {
+ Diag(Loc, diag::warn_objc_property_assign_on_object);
+ }
+
// Check for more than one of { assign, copy, retain }.
if (Attributes & ObjCDeclSpec::DQ_PR_assign) {
if (Attributes & ObjCDeclSpec::DQ_PR_copy) {