summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Analysis/CFRefCount.cpp6
-rw-r--r--clang/lib/Frontend/PCHReaderDecl.cpp1
-rw-r--r--clang/lib/Frontend/PCHWriter.cpp1
-rw-r--r--clang/lib/Parse/AttributeList.cpp1
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp47
5 files changed, 46 insertions, 10 deletions
diff --git a/clang/lib/Analysis/CFRefCount.cpp b/clang/lib/Analysis/CFRefCount.cpp
index 976bfad188d..07dbf10c408 100644
--- a/clang/lib/Analysis/CFRefCount.cpp
+++ b/clang/lib/Analysis/CFRefCount.cpp
@@ -1128,6 +1128,9 @@ RetainSummaryManager::updateSummaryFromAnnotations(RetainSummary &Summ,
? RetEffect::MakeGCNotOwned()
: RetEffect::MakeOwned(RetEffect::ObjC, true));
}
+ else if (FD->getAttr<CFOwnershipReturnsAttr>()) {
+ Summ.setRetEffect(RetEffect::MakeOwned(RetEffect::CF, true));
+ }
}
// Determine if there are any arguments with a specific ArgEffect.
@@ -1150,6 +1153,9 @@ RetainSummaryManager::updateSummaryFromAnnotations(RetainSummary &Summ,
? RetEffect::MakeGCNotOwned()
: RetEffect::MakeOwned(RetEffect::ObjC, true));
}
+ else if (MD->getAttr<CFOwnershipReturnsAttr>()) {
+ Summ.setRetEffect(RetEffect::MakeOwned(RetEffect::CF, true));
+ }
}
// Determine if there are any arguments with a specific ArgEffect.
diff --git a/clang/lib/Frontend/PCHReaderDecl.cpp b/clang/lib/Frontend/PCHReaderDecl.cpp
index ff2eb9f7c92..7bcd296bce2 100644
--- a/clang/lib/Frontend/PCHReaderDecl.cpp
+++ b/clang/lib/Frontend/PCHReaderDecl.cpp
@@ -477,6 +477,7 @@ Attr *PCHReader::ReadAttributes() {
SIMPLE_ATTR(ObjCNSObject);
SIMPLE_ATTR(CFOwnershipRelease);
SIMPLE_ATTR(CFOwnershipRetain);
+ SIMPLE_ATTR(CFOwnershipReturns);
SIMPLE_ATTR(NSOwnershipRelease);
SIMPLE_ATTR(NSOwnershipRetain);
SIMPLE_ATTR(NSOwnershipReturns);
diff --git a/clang/lib/Frontend/PCHWriter.cpp b/clang/lib/Frontend/PCHWriter.cpp
index a1f0cb7f4fe..98ed063305c 100644
--- a/clang/lib/Frontend/PCHWriter.cpp
+++ b/clang/lib/Frontend/PCHWriter.cpp
@@ -1551,6 +1551,7 @@ void PCHWriter::WriteAttributeRecord(const Attr *Attr) {
case Attr::ObjCNSObject:
case Attr::CFOwnershipRelease:
case Attr::CFOwnershipRetain:
+ case Attr::CFOwnershipReturns:
case Attr::NSOwnershipRelease:
case Attr::NSOwnershipRetain:
case Attr::NSOwnershipReturns:
diff --git a/clang/lib/Parse/AttributeList.cpp b/clang/lib/Parse/AttributeList.cpp
index 1cc9a51ec6f..933e9f2b09b 100644
--- a/clang/lib/Parse/AttributeList.cpp
+++ b/clang/lib/Parse/AttributeList.cpp
@@ -132,6 +132,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) {
break;
case 16:
if (!memcmp(Str, "ns_returns_owned", 16)) return AT_ns_returns_owned;
+ if (!memcmp(Str, "cf_returns_owned", 16)) return AT_cf_returns_owned;
break;
case 17:
if (!memcmp(Str, "transparent_union", 17)) return AT_transparent_union;
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 033be2c9622..926e5fda68d 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -1548,15 +1548,37 @@ static void HandleRegparmAttr(Decl *d, const AttributeList &Attr, Sema &S) {
//===----------------------------------------------------------------------===//
static void HandleNSOwnershipReturnsAttr(Decl *d, const AttributeList &Attr,
- Sema &S) {
+ Sema &S) {
if (!isa<ObjCMethodDecl>(d) && !isa<FunctionDecl>(d)) {
+ const char *name;
+
+ switch (Attr.getKind()) {
+ default:
+ assert(0 && "invalid ownership attribute");
+ return;
+ case AttributeList::AT_cf_returns_owned:
+ name = "cf_returns_owned"; break;
+ case AttributeList::AT_ns_returns_owned:
+ name = "ns_returns_owned"; break;
+ };
+
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) <<
- "ns_returns_owned" << 3 /* function or method */;
+ name << 3 /* function or method */;
return;
}
- d->addAttr(::new (S.Context) NSOwnershipReturnsAttr());
+ switch (Attr.getKind()) {
+ default:
+ assert(0 && "invalid ownership attribute");
+ return;
+ case AttributeList::AT_cf_returns_owned:
+ d->addAttr(::new (S.Context) CFOwnershipReturnsAttr());
+ return;
+ case AttributeList::AT_ns_returns_owned:
+ d->addAttr(::new (S.Context) NSOwnershipReturnsAttr());
+ return;
+ };
}
static void HandleNSOwnershipAttr(Decl *d, const AttributeList &Attr,
@@ -1579,9 +1601,9 @@ static void HandleNSOwnershipAttr(Decl *d, const AttributeList &Attr,
name = "ns_retains"; break;
};
- S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) << name
- << (attachToMethodDecl ? 5 /* parameter or method decl */
- : 4 /* parameter */);
+ S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) <<
+ name << (attachToMethodDecl ? 5 /* parameter or method decl */
+ : 4 /* parameter */);
return;
}
@@ -1590,13 +1612,17 @@ static void HandleNSOwnershipAttr(Decl *d, const AttributeList &Attr,
assert(0 && "invalid ownership attribute");
return;
case AttributeList::AT_cf_releases:
- d->addAttr(::new (S.Context) CFOwnershipReleaseAttr()); return;
+ d->addAttr(::new (S.Context) CFOwnershipReleaseAttr());
+ return;
case AttributeList::AT_cf_retains:
- d->addAttr(::new (S.Context) CFOwnershipRetainAttr()); return;
+ d->addAttr(::new (S.Context) CFOwnershipRetainAttr());
+ return;
case AttributeList::AT_ns_releases:
- d->addAttr(::new (S.Context) NSOwnershipReleaseAttr()); return;
+ d->addAttr(::new (S.Context) NSOwnershipReleaseAttr());
+ return;
case AttributeList::AT_ns_retains:
- d->addAttr(::new (S.Context) NSOwnershipRetainAttr()); return;
+ d->addAttr(::new (S.Context) NSOwnershipRetainAttr());
+ return;
}
}
@@ -1645,6 +1671,7 @@ static void ProcessDeclAttribute(Decl *D, const AttributeList &Attr, Sema &S) {
case AttributeList::AT_ns_retains:
HandleNSOwnershipAttr(D, Attr, S, true); break;
case AttributeList::AT_ns_returns_owned:
+ case AttributeList::AT_cf_returns_owned:
HandleNSOwnershipReturnsAttr(D, Attr, S); break;
case AttributeList::AT_packed: HandlePackedAttr (D, Attr, S); break;
OpenPOWER on IntegriCloud