aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDeclObjC.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2012-09-12 20:34:47 +0000
committerFariborz Jahanian <fjahanian@apple.com>2012-09-12 20:34:47 +0000
commit00024796eaa29055e76fc99ffdc668c702e6fe9d (patch)
tree840d39bc00c187bfa8aeebf80e3175a8675092f3 /lib/Sema/SemaDeclObjC.cpp
parenta912649ebfc9b06918060286f889822f72fabb01 (diff)
objective-C arc: don't issue no explicit ownership warning when
__autoreleasing is explicitely added to param type. // rdar://12280826 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163738 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclObjC.cpp')
-rw-r--r--lib/Sema/SemaDeclObjC.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index e81429cc4c..2dc2b0cba1 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -282,11 +282,10 @@ void Sema::AddAnyMethodToGlobalPool(Decl *D) {
AddFactoryMethodToGlobalPool(MDecl, true);
}
-/// StrongPointerToObjCPointer - returns true when pointer to ObjC pointer
-/// is __strong, or when it is any other type. It returns false when
-/// pointer to ObjC pointer is not __strong.
+/// HasExplicitOwnershipAttr - returns true when pointer to ObjC pointer
+/// has explicit ownership attribute; false otherwise.
static bool
-StrongPointerToObjCPointer(Sema &S, ParmVarDecl *Param) {
+HasExplicitOwnershipAttr(Sema &S, ParmVarDecl *Param) {
QualType T = Param->getType();
if (!T->isObjCIndirectLifetimeType())
return true;
@@ -296,8 +295,11 @@ StrongPointerToObjCPointer(Sema &S, ParmVarDecl *Param) {
? T->getAs<PointerType>()->getPointeeType()
: T->getAs<ReferenceType>()->getPointeeType();
if (T->isObjCLifetimeType()) {
- Qualifiers::ObjCLifetime lifetime = T.getObjCLifetime();
- return lifetime == Qualifiers::OCL_Strong;
+ // when lifetime is Qualifiers::OCL_None it means that it has
+ // no implicit ownership qualifier (which means it is explicit).
+ Qualifiers::ObjCLifetime lifetime =
+ T.getLocalQualifiers().getObjCLifetime();
+ return lifetime == Qualifiers::OCL_None;
}
return true;
}
@@ -335,7 +337,7 @@ void Sema::ActOnStartOfObjCMethodDef(Scope *FnBodyScope, Decl *D) {
Param->setInvalidDecl();
if (!Param->isInvalidDecl() &&
getLangOpts().ObjCAutoRefCount &&
- !StrongPointerToObjCPointer(*this, Param))
+ !HasExplicitOwnershipAttr(*this, Param))
Diag(Param->getLocation(), diag::warn_arc_strong_pointer_objc_pointer) <<
Param->getType();