ObjCNSObject,
CFOwnershipRelease, // Clang/Checker-specific.
CFOwnershipRetain, // Clang/Checker-specific.
- ObjCOwnershipMakeCollectable, // Clang/Checker-specific.
- ObjCOwnershipRelease, // Clang/Checker-specific.
- ObjCOwnershipRetain, // Clang/Checker-specific.
- ObjCOwnershipReturns, // Clang/Checker-specific.
+ NSOwnershipMakeCollectable, // Clang/Checker-specific.
+ NSOwnershipRelease, // Clang/Checker-specific.
+ NSOwnershipRetain, // Clang/Checker-specific.
+ NSOwnershipReturns, // Clang/Checker-specific.
Overloadable, // Clang-specific
Packed,
Pure,
// Checker-specific attributes.
DEF_SIMPLE_ATTR(CFOwnershipRelease);
-DEF_SIMPLE_ATTR(ObjCOwnershipRelease);
+DEF_SIMPLE_ATTR(NSOwnershipRelease);
DEF_SIMPLE_ATTR(CFOwnershipRetain);
-DEF_SIMPLE_ATTR(ObjCOwnershipRetain);
-DEF_SIMPLE_ATTR(ObjCOwnershipMakeCollectable);
-DEF_SIMPLE_ATTR(ObjCOwnershipReturns);
+DEF_SIMPLE_ATTR(NSOwnershipRetain);
+DEF_SIMPLE_ATTR(NSOwnershipMakeCollectable);
+DEF_SIMPLE_ATTR(NSOwnershipReturns);
#undef DEF_SIMPLE_ATTR
AT_objc_exception,
AT_cf_ownership_release, // Clang-specific.
AT_cf_ownership_retain, // Clang-specific.
- AT_objc_ownership_make_collectable, // Clang-specific.
- AT_objc_ownership_release, // Clang-specific.
- AT_objc_ownership_retain, // Clang-specific.
- AT_objc_ownership_returns, // Clang-specific.
+ AT_ns_ownership_make_collectable, // Clang-specific.
+ AT_ns_ownership_release, // Clang-specific.
+ AT_ns_ownership_retain, // Clang-specific.
+ AT_ns_ownership_returns, // Clang-specific.
AT_objc_gc,
AT_overloadable, // Clang-specific.
AT_packed,
RetainSummaryManager::updateSummaryArgEffFromAnnotations(RetainSummary &Summ,
unsigned i,
const ParmVarDecl *PD){
- if (PD->getAttr<ObjCOwnershipRetainAttr>())
+ if (PD->getAttr<NSOwnershipRetainAttr>())
Summ.setArgEffect(AF, i, IncRefMsg);
else if (PD->getAttr<CFOwnershipRetainAttr>())
Summ.setArgEffect(AF, i, IncRef);
- else if (PD->getAttr<ObjCOwnershipReleaseAttr>())
+ else if (PD->getAttr<NSOwnershipReleaseAttr>())
Summ.setArgEffect(AF, i, DecRefMsg);
else if (PD->getAttr<CFOwnershipReleaseAttr>())
Summ.setArgEffect(AF, i, DecRef);
- else if (PD->getAttr<ObjCOwnershipMakeCollectableAttr>())
+ else if (PD->getAttr<NSOwnershipMakeCollectableAttr>())
Summ.setArgEffect(AF, i, MakeCollectable);
}
// Determine if there is a special return effect for this method.
if (isTrackedObjCObjectType(FD->getResultType())) {
- if (FD->getAttr<ObjCOwnershipReturnsAttr>()) {
+ if (FD->getAttr<NSOwnershipReturnsAttr>()) {
Summ.setRetEffect(isGCEnabled()
? RetEffect::MakeGCNotOwned()
: RetEffect::MakeOwned(RetEffect::ObjC, true));
// Determine if there is a special return effect for this method.
if (isTrackedObjCObjectType(MD->getResultType())) {
- if (MD->getAttr<ObjCOwnershipReturnsAttr>()) {
+ if (MD->getAttr<NSOwnershipReturnsAttr>()) {
Summ.setRetEffect(isGCEnabled()
? RetEffect::MakeGCNotOwned()
: RetEffect::MakeOwned(RetEffect::ObjC, true));
updateSummaryArgEffFromAnnotations(Summ, i, *I);
// Determine any effects on the receiver.
- if (MD->getAttr<ObjCOwnershipRetainAttr>())
+ if (MD->getAttr<NSOwnershipRetainAttr>())
Summ.setReceiverEffect(IncRefMsg);
- else if (MD->getAttr<ObjCOwnershipReleaseAttr>())
+ else if (MD->getAttr<NSOwnershipReleaseAttr>())
Summ.setReceiverEffect(DecRefMsg);
}
SIMPLE_ATTR(ObjCNSObject);
SIMPLE_ATTR(CFOwnershipRelease);
SIMPLE_ATTR(CFOwnershipRetain);
- SIMPLE_ATTR(ObjCOwnershipMakeCollectable);
- SIMPLE_ATTR(ObjCOwnershipRelease);
- SIMPLE_ATTR(ObjCOwnershipRetain);
- SIMPLE_ATTR(ObjCOwnershipReturns);
+ SIMPLE_ATTR(NSOwnershipMakeCollectable);
+ SIMPLE_ATTR(NSOwnershipRelease);
+ SIMPLE_ATTR(NSOwnershipRetain);
+ SIMPLE_ATTR(NSOwnershipReturns);
SIMPLE_ATTR(Overloadable);
UNSIGNED_ATTR(Packed);
SIMPLE_ATTR(Pure);
case Attr::ObjCNSObject:
case Attr::CFOwnershipRelease:
case Attr::CFOwnershipRetain:
- case Attr::ObjCOwnershipMakeCollectable:
- case Attr::ObjCOwnershipRelease:
- case Attr::ObjCOwnershipRetain:
- case Attr::ObjCOwnershipReturns:
+ case Attr::NSOwnershipMakeCollectable:
+ case Attr::NSOwnershipRelease:
+ case Attr::NSOwnershipRetain:
+ case Attr::NSOwnershipReturns:
case Attr::Overloadable:
break;
case 19:
if (!memcmp(Str, "cf_ownership_retain", 19))
return AT_cf_ownership_retain;
+ if (!memcmp(Str, "ns_ownership_retain", 19))
+ return AT_ns_ownership_retain;
break;
case 20:
if (!memcmp(Str, "cf_ownership_release", 20))
return AT_cf_ownership_release;
- break;
- case 21:
- if (!memcmp(Str, "objc_ownership_retain", 21))
- return AT_objc_ownership_retain;
+ if (!memcmp(Str, "ns_ownership_release", 20))
+ return AT_ns_ownership_release;
+ if (!memcmp(Str, "ns_ownership_returns", 20))
+ return AT_ns_ownership_returns;
break;
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;
- case 31:
- if (!memcmp(Str, "objc_ownership_make_collectable", 31))
- return AT_objc_ownership_make_collectable;
+ case 29:
+ if (!memcmp(Str, "ns_ownership_make_collectable", 29))
+ return AT_ns_ownership_make_collectable;
break;
}
return UnknownAttribute;
// Checker-specific attribute handlers.
//===----------------------------------------------------------------------===//
-static void HandleObjCOwnershipReturnsAttr(Decl *d, const AttributeList &Attr,
+static void HandleNSOwnershipReturnsAttr(Decl *d, const AttributeList &Attr,
Sema &S) {
if (!isa<ObjCMethodDecl>(d) && !isa<FunctionDecl>(d)) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) <<
- "objc_ownership_returns" << 3 /* function or method */;
+ "ns_ownership_returns" << 3 /* function or method */;
return;
}
- d->addAttr(::new (S.Context) ObjCOwnershipReturnsAttr());
+ d->addAttr(::new (S.Context) NSOwnershipReturnsAttr());
}
-static void HandleObjCOwnershipAttr(Decl *d, const AttributeList &Attr,
+static void HandleNSOwnershipAttr(Decl *d, const AttributeList &Attr,
Sema &S, bool attachToMethodDecl = false) {
if (!isa<ParmVarDecl>(d) && (!attachToMethodDecl || !isa<ObjCMethodDecl>(d))){
name = "cf_ownership_release"; break;
case AttributeList::AT_cf_ownership_retain:
name = "cf_ownership_retain"; break;
- case AttributeList::AT_objc_ownership_make_collectable:
- name = "objc_ownership_make_collectable"; break;
- case AttributeList::AT_objc_ownership_release:
- name = "objc_ownership_release"; break;
- case AttributeList::AT_objc_ownership_retain:
- name = "objc_ownership_retain"; break;
+ case AttributeList::AT_ns_ownership_make_collectable:
+ name = "ns_ownership_make_collectable"; break;
+ case AttributeList::AT_ns_ownership_release:
+ name = "ns_ownership_release"; break;
+ case AttributeList::AT_ns_ownership_retain:
+ name = "ns_ownership_retain"; break;
};
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) << name
d->addAttr(::new (S.Context) CFOwnershipReleaseAttr()); return;
case AttributeList::AT_cf_ownership_retain:
d->addAttr(::new (S.Context) CFOwnershipRetainAttr()); return;
- case AttributeList::AT_objc_ownership_make_collectable:
- d->addAttr(::new (S.Context) ObjCOwnershipMakeCollectableAttr()); return;
- case AttributeList::AT_objc_ownership_release:
- d->addAttr(::new (S.Context) ObjCOwnershipReleaseAttr()); return;
- case AttributeList::AT_objc_ownership_retain:
- d->addAttr(::new (S.Context) ObjCOwnershipRetainAttr()); return;
+ case AttributeList::AT_ns_ownership_make_collectable:
+ d->addAttr(::new (S.Context) NSOwnershipMakeCollectableAttr()); return;
+ case AttributeList::AT_ns_ownership_release:
+ d->addAttr(::new (S.Context) NSOwnershipReleaseAttr()); return;
+ case AttributeList::AT_ns_ownership_retain:
+ d->addAttr(::new (S.Context) NSOwnershipRetainAttr()); return;
}
}
// Checker-specific.
case AttributeList::AT_cf_ownership_release:
case AttributeList::AT_cf_ownership_retain:
- HandleObjCOwnershipAttr(D, Attr, S); break;
- case AttributeList::AT_objc_ownership_make_collectable:
- case AttributeList::AT_objc_ownership_release:
- case AttributeList::AT_objc_ownership_retain:
- HandleObjCOwnershipAttr(D, Attr, S, true); break;
- case AttributeList::AT_objc_ownership_returns:
- HandleObjCOwnershipReturnsAttr(D, Attr, S); break;
+ HandleNSOwnershipAttr(D, Attr, S); break;
+ case AttributeList::AT_ns_ownership_make_collectable:
+ case AttributeList::AT_ns_ownership_release:
+ case AttributeList::AT_ns_ownership_retain:
+ HandleNSOwnershipAttr(D, Attr, S, true); break;
+ case AttributeList::AT_ns_ownership_returns:
+ HandleNSOwnershipReturnsAttr(D, Attr, S); break;
case AttributeList::AT_packed: HandlePackedAttr (D, Attr, S); break;
case AttributeList::AT_section: HandleSectionAttr (D, Attr, S); break;
//===----------------------------------------------------------------------===//
@interface TestOwnershipAttr : NSObject
-- (NSString*) returnsAnOwnedString __attribute__((objc_ownership_returns));
-- (void) myRetain:(id)__attribute__((objc_ownership_retain))obj;
+- (NSString*) returnsAnOwnedString __attribute__((ns_ownership_returns));
+- (void) myRetain:(id)__attribute__((ns_ownership_retain))obj;
- (void) myCFRetain:(id)__attribute__((cf_ownership_retain))obj;
-- (void) myRelease:(id)__attribute__((objc_ownership_release))obj;
+- (void) myRelease:(id)__attribute__((ns_ownership_release))obj;
- (void) myCFRelease:(id)__attribute__((cf_ownership_release))obj;
-- (void) makeCollectable:(id)__attribute__((objc_ownership_make_collectable))obj;
+- (void) makeCollectable:(id)__attribute__((ns_ownership_make_collectable))obj;
@end
void test_attr_1(TestOwnershipAttr *X) {
//===----------------------------------------------------------------------===//
@interface TestOwnershipAttr : NSObject
-- (NSString*) returnsAnOwnedString __attribute__((objc_ownership_returns));
-- (void) myRetain:(id)__attribute__((objc_ownership_retain))obj;
+- (NSString*) returnsAnOwnedString __attribute__((ns_ownership_returns));
+- (void) myRetain:(id)__attribute__((ns_ownership_retain))obj;
- (void) myCFRetain:(id)__attribute__((cf_ownership_retain))obj;
-- (void) myRelease:(id)__attribute__((objc_ownership_release))obj;
+- (void) myRelease:(id)__attribute__((ns_ownership_release))obj;
- (void) myCFRelease:(id)__attribute__((cf_ownership_release))obj;
-- (void) myRetain __attribute__((objc_ownership_retain));
-- (void) myRelease __attribute__((objc_ownership_release));
+- (void) myRetain __attribute__((ns_ownership_retain));
+- (void) myRelease __attribute__((ns_ownership_release));
@end
@interface TestAttrHelper : NSObject
- (NSString*) createString:(TestOwnershipAttr*)X;
-- (NSString*) createStringAttr:(TestOwnershipAttr*)X __attribute__((objc_ownership_returns));
+- (NSString*) createStringAttr:(TestOwnershipAttr*)X __attribute__((ns_ownership_returns));
@end
@implementation TestAttrHelper