diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-06-25 00:17:46 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-06-25 00:17:46 +0000 |
commit | 831fb9622581fc3b777848e6b097a0cb23d124de (patch) | |
tree | 4f39c6cba98cf0045b3748c0f0f13ff8934a14dd /lib/Sema/SemaObjCProperty.cpp | |
parent | 88c1dfccf8c5d487408e3365c752ed24c867c7ce (diff) |
objc-arc/mrc: Allow ns_returns_not_retained attribute on properties
to turn off warning on those properties which follow Cocoa naming
convention for retaining objects and yet they were not meant for
such purposes. Also, perform consistancy checking for declared
getters of such methods. // rdar://9636091
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133849 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaObjCProperty.cpp')
-rw-r--r-- | lib/Sema/SemaObjCProperty.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 22f9b3e092..012e2569c3 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -737,6 +737,12 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, PIDecl->setGetterCXXConstructor(ResExpr); } } + if (property->hasAttr<NSReturnsNotRetainedAttr>() && + !getterMethod->hasAttr<NSReturnsNotRetainedAttr>()) { + Diag(getterMethod->getLocation(), + diag::warn_property_getter_owning_mismatch); + Diag(property->getLocation(), diag::note_property_declare); + } } if (ObjCMethodDecl *setterMethod = property->getSetterMethodDecl()) { setterMethod->createImplicitParams(Context, IDecl); @@ -1369,7 +1375,8 @@ void Sema::DiagnoseOwningPropertyGetterSynthesis(const ObjCImplementationDecl *D continue; const ObjCPropertyDecl *PD = PID->getPropertyDecl(); - if (PD && !D->getInstanceMethod(PD->getGetterName())) { + if (PD && !PD->hasAttr<NSReturnsNotRetainedAttr>() && + !D->getInstanceMethod(PD->getGetterName())) { ObjCMethodDecl *method = PD->getGetterMethodDecl(); if (!method) continue; @@ -1465,6 +1472,9 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property, // and the real context should be the same. if (lexicalDC) GetterMethod->setLexicalDeclContext(lexicalDC); + if (property->hasAttr<NSReturnsNotRetainedAttr>()) + GetterMethod->addAttr( + ::new (Context) NSReturnsNotRetainedAttr(Loc, Context)); } else // A user declared getter will be synthesize when @synthesize of // the property with the same name is seen in the @implementation |