aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-04-27 19:36:56 +0000
committerTed Kremenek <kremenek@apple.com>2009-04-27 19:36:56 +0000
commitc6a59e4bf225c7f8152faca72897321f0f6cabd1 (patch)
tree743e88ed65481afd096241a4f5a4371b4f8abe02 /lib
parente798e7c5a107ff5262005431817409a855a67922 (diff)
Add two new checker-specific attributes: 'objc_ownership_release' and
'objc_ownership_cfrelease'. These are the 'release' equivalents of 'objc_ownership_retain' and 'objc_ownership_cfretain' respectively. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70235 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/CFRefCount.cpp10
-rw-r--r--lib/Frontend/PCHReaderDecl.cpp2
-rw-r--r--lib/Frontend/PCHWriter.cpp2
-rw-r--r--lib/Parse/AttributeList.cpp8
-rw-r--r--lib/Sema/SemaDeclAttr.cpp10
5 files changed, 30 insertions, 2 deletions
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp
index 8f07b2c9f4..538f4f2722 100644
--- a/lib/Analysis/CFRefCount.cpp
+++ b/lib/Analysis/CFRefCount.cpp
@@ -1112,7 +1112,15 @@ RetainSummaryManager::getMethodSummaryFromAnnotations(ObjCMethodDecl *MD) {
else if ((*I)->getAttr<ObjCOwnershipCFRetainAttr>()) {
ScratchArgs.push_back(std::make_pair(i, IncRef));
hasArgEffect = true;
- }
+ }
+ else if ((*I)->getAttr<ObjCOwnershipReleaseAttr>()) {
+ ScratchArgs.push_back(std::make_pair(i, DecRefMsg));
+ hasArgEffect = true;
+ }
+ else if ((*I)->getAttr<ObjCOwnershipCFReleaseAttr>()) {
+ ScratchArgs.push_back(std::make_pair(i, DecRef));
+ hasArgEffect = true;
+ }
}
if (!hasRetEffect && !hasArgEffect)
diff --git a/lib/Frontend/PCHReaderDecl.cpp b/lib/Frontend/PCHReaderDecl.cpp
index 50cc031225..2df87bfe1c 100644
--- a/lib/Frontend/PCHReaderDecl.cpp
+++ b/lib/Frontend/PCHReaderDecl.cpp
@@ -475,6 +475,8 @@ Attr *PCHReader::ReadAttributes() {
SIMPLE_ATTR(ObjCException);
SIMPLE_ATTR(ObjCNSObject);
+ SIMPLE_ATTR(ObjCOwnershipCFRelease);
+ SIMPLE_ATTR(ObjCOwnershipRelease);
SIMPLE_ATTR(ObjCOwnershipCFRetain);
SIMPLE_ATTR(ObjCOwnershipRetain);
SIMPLE_ATTR(ObjCOwnershipReturns);
diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp
index bb85b68b7e..8ff688e6e3 100644
--- a/lib/Frontend/PCHWriter.cpp
+++ b/lib/Frontend/PCHWriter.cpp
@@ -1539,6 +1539,8 @@ void PCHWriter::WriteAttributeRecord(const Attr *Attr) {
case Attr::ObjCException:
case Attr::ObjCNSObject:
+ case Attr::ObjCOwnershipCFRelease:
+ case Attr::ObjCOwnershipRelease:
case Attr::ObjCOwnershipCFRetain:
case Attr::ObjCOwnershipRetain:
case Attr::ObjCOwnershipReturns:
diff --git a/lib/Parse/AttributeList.cpp b/lib/Parse/AttributeList.cpp
index 9e46159153..cbc0031428 100644
--- a/lib/Parse/AttributeList.cpp
+++ b/lib/Parse/AttributeList.cpp
@@ -140,6 +140,8 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) {
case 22:
if (!memcmp(Str, "objc_ownership_returns", 22))
return AT_objc_ownership_returns;
+ if (!memcmp(Str, "objc_ownership_release", 22))
+ return AT_objc_ownership_release;
if (!memcmp(Str, "no_instrument_function", 22))
return AT_no_instrument_function;
break;
@@ -147,6 +149,10 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) {
if (!memcmp(Str, "objc_ownership_cfretain", 23))
return AT_objc_ownership_cfretain;
break;
- }
+ case 24:
+ if (!memcmp(Str, "objc_ownership_cfrelease", 24))
+ return AT_objc_ownership_cfrelease;
+ break;
+ }
return UnknownAttribute;
}
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index cf722e511d..c72b7ad7e8 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -1543,6 +1543,10 @@ static void HandleObjCOwnershipParmAttr(Decl *d, const AttributeList &Attr,
default:
assert(0 && "invalid ownership attribute");
return;
+ case AttributeList::AT_objc_ownership_release:
+ name = "objc_ownership_release"; break;
+ case AttributeList::AT_objc_ownership_cfrelease:
+ name = "objc_ownership_cfrelease"; break;
case AttributeList::AT_objc_ownership_retain:
name = "objc_ownership_retain"; break;
case AttributeList::AT_objc_ownership_cfretain:
@@ -1558,6 +1562,10 @@ static void HandleObjCOwnershipParmAttr(Decl *d, const AttributeList &Attr,
default:
assert(0 && "invalid ownership attribute");
return;
+ case AttributeList::AT_objc_ownership_release:
+ d->addAttr(::new (S.Context) ObjCOwnershipReleaseAttr()); return;
+ case AttributeList::AT_objc_ownership_cfrelease:
+ d->addAttr(::new (S.Context) ObjCOwnershipCFReleaseAttr()); return;
case AttributeList::AT_objc_ownership_retain:
d->addAttr(::new (S.Context) ObjCOwnershipRetainAttr()); return;
case AttributeList::AT_objc_ownership_cfretain:
@@ -1603,6 +1611,8 @@ static void ProcessDeclAttribute(Decl *D, const AttributeList &Attr, Sema &S) {
case AttributeList::AT_nothrow: HandleNothrowAttr (D, Attr, S); break;
// Checker-specific.
+ case AttributeList::AT_objc_ownership_release:
+ case AttributeList::AT_objc_ownership_cfrelease:
case AttributeList::AT_objc_ownership_retain:
case AttributeList::AT_objc_ownership_cfretain:
HandleObjCOwnershipParmAttr(D, Attr, S); break;