From 11fd5cf9fd813938a0d3140fb878851c22d67a65 Mon Sep 17 00:00:00 2001 From: John McCall Date: Wed, 5 Sep 2018 19:02:00 +0000 Subject: 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 --- lib/Sema/SemaObjCProperty.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/Sema/SemaObjCProperty.cpp') 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) { -- cgit v1.2.1