diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-04-27 18:27:22 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-04-27 18:27:22 +0000 |
commit | 4064de959853503d9b87065adac1b277fff8af20 (patch) | |
tree | 462ca0454b2afdedf3b9c994e656912b1191baf5 /lib | |
parent | f331fb40fd92242980792e1af01ec72b74f3379e (diff) |
Add new checker-specific attribute 'objc_ownership_cfretain'. This is the same
as 'objc_ownership_cfretain' except that the method acts like a CFRetain instead
of a [... retain] (important in GC modes). Checker support is wired up, but
currently only for Objective-C message expressions (not function calls).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70218 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/CFRefCount.cpp | 6 | ||||
-rw-r--r-- | lib/Frontend/PCHReaderDecl.cpp | 1 | ||||
-rw-r--r-- | lib/Frontend/PCHWriter.cpp | 1 | ||||
-rw-r--r-- | lib/Parse/AttributeList.cpp | 5 | ||||
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 14 |
5 files changed, 26 insertions, 1 deletions
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp index c2369abb2c..6223e7cdba 100644 --- a/lib/Analysis/CFRefCount.cpp +++ b/lib/Analysis/CFRefCount.cpp @@ -1104,7 +1104,11 @@ RetainSummaryManager::getMethodSummaryFromAnnotations(ObjCMethodDecl *MD) { ScratchArgs.push_back(std::make_pair(i, IncRefMsg)); hasArgEffect = true; } -} + else if ((*I)->getAttr<ObjCOwnershipCFRetainAttr>()) { + ScratchArgs.push_back(std::make_pair(i, IncRef)); + hasArgEffect = true; + } + } if (!hasRetEffect && !hasArgEffect) return 0; diff --git a/lib/Frontend/PCHReaderDecl.cpp b/lib/Frontend/PCHReaderDecl.cpp index 508d2ef170..50cc031225 100644 --- a/lib/Frontend/PCHReaderDecl.cpp +++ b/lib/Frontend/PCHReaderDecl.cpp @@ -475,6 +475,7 @@ Attr *PCHReader::ReadAttributes() { SIMPLE_ATTR(ObjCException); SIMPLE_ATTR(ObjCNSObject); + SIMPLE_ATTR(ObjCOwnershipCFRetain); SIMPLE_ATTR(ObjCOwnershipRetain); SIMPLE_ATTR(ObjCOwnershipReturns); SIMPLE_ATTR(Overloadable); diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp index 82eb5dffe4..391a1f9165 100644 --- a/lib/Frontend/PCHWriter.cpp +++ b/lib/Frontend/PCHWriter.cpp @@ -1420,6 +1420,7 @@ void PCHWriter::WriteAttributeRecord(const Attr *Attr) { case Attr::ObjCException: case Attr::ObjCNSObject: + case Attr::ObjCOwnershipCFRetain: case Attr::ObjCOwnershipRetain: case Attr::ObjCOwnershipReturns: case Attr::Overloadable: diff --git a/lib/Parse/AttributeList.cpp b/lib/Parse/AttributeList.cpp index a9c552ba17..9e46159153 100644 --- a/lib/Parse/AttributeList.cpp +++ b/lib/Parse/AttributeList.cpp @@ -136,12 +136,17 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) { case 21: if (!memcmp(Str, "objc_ownership_retain", 21)) return AT_objc_ownership_retain; + break; case 22: if (!memcmp(Str, "objc_ownership_returns", 22)) return AT_objc_ownership_returns; if (!memcmp(Str, "no_instrument_function", 22)) return AT_no_instrument_function; break; + case 23: + if (!memcmp(Str, "objc_ownership_cfretain", 23)) + return AT_objc_ownership_cfretain; + break; } return UnknownAttribute; } diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index c0a3b44c43..7bbfb26954 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -1545,6 +1545,18 @@ static void HandleObjCOwnershipRetainAttr(Decl *d, const AttributeList &Attr, d->addAttr(::new (S.Context) ObjCOwnershipRetainAttr()); } +static void HandleObjCOwnershipCFRetainAttr(Decl *d, const AttributeList &Attr, + Sema &S) { + + if (!isa<ParmVarDecl>(d)) { + S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) << + "objc_ownership_cfretain" << 4 /* parameter */; + return; + } + + d->addAttr(::new (S.Context) ObjCOwnershipCFRetainAttr()); +} + //===----------------------------------------------------------------------===// // Top Level Sema Entry Points //===----------------------------------------------------------------------===// @@ -1587,6 +1599,8 @@ static void ProcessDeclAttribute(Decl *D, const AttributeList &Attr, Sema &S) { HandleObjCOwnershipRetainAttr(D, Attr, S); break; case AttributeList::AT_objc_ownership_returns: HandleObjCOwnershipReturnsAttr(D, Attr, S); break; + case AttributeList::AT_objc_ownership_cfretain: + HandleObjCOwnershipCFRetainAttr(D, Attr, S); break; case AttributeList::AT_packed: HandlePackedAttr (D, Attr, S); break; case AttributeList::AT_section: HandleSectionAttr (D, Attr, S); break; |