NonNull,
ObjCException,
ObjCNSObject,
- ObjCOwnershipCFRelease, // Clang/Checker-specific.
- ObjCOwnershipCFRetain, // Clang/Checker-specific.
- ObjCOwnershipRelease, // Clang/Checker-specific.
- ObjCOwnershipRetain, // Clang/Checker-specific.
- ObjCOwnershipReturns, // Clang/Checker-specific.
+ ObjCOwnershipCFRelease, // Clang/Checker-specific.
+ ObjCOwnershipCFRetain, // Clang/Checker-specific.
+ ObjCOwnershipMakeCollectable, // Clang/Checker-specific.
+ ObjCOwnershipRelease, // Clang/Checker-specific.
+ ObjCOwnershipRetain, // Clang/Checker-specific.
+ ObjCOwnershipReturns, // Clang/Checker-specific.
Overloadable, // Clang-specific
Packed,
Pure,
DEF_SIMPLE_ATTR(ObjCOwnershipRelease);
DEF_SIMPLE_ATTR(ObjCOwnershipCFRetain);
DEF_SIMPLE_ATTR(ObjCOwnershipRetain);
+DEF_SIMPLE_ATTR(ObjCOwnershipMakeCollectable);
DEF_SIMPLE_ATTR(ObjCOwnershipReturns);
#undef DEF_SIMPLE_ATTR
AT_nothrow,
AT_nsobject,
AT_objc_exception,
- AT_objc_ownership_cfrelease, // Clang-specific.
- AT_objc_ownership_cfretain, // Clang-specific.
- AT_objc_ownership_release, // Clang-specific.
- AT_objc_ownership_retain, // Clang-specific.
- AT_objc_ownership_returns, // Clang-specific.
+ AT_objc_ownership_cfrelease, // Clang-specific.
+ AT_objc_ownership_cfretain, // 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_objc_gc,
AT_overloadable, // Clang-specific.
AT_packed,
ScratchArgs.push_back(std::make_pair(i, DecRef));
hasArgEffect = true;
}
+ else if ((*I)->getAttr<ObjCOwnershipMakeCollectableAttr>()) {
+ ScratchArgs.push_back(std::make_pair(i, MakeCollectable));
+ hasArgEffect = true;
+ }
}
if (!hasRetEffect && !hasArgEffect)
SIMPLE_ATTR(ObjCException);
SIMPLE_ATTR(ObjCNSObject);
SIMPLE_ATTR(ObjCOwnershipCFRelease);
- SIMPLE_ATTR(ObjCOwnershipRelease);
SIMPLE_ATTR(ObjCOwnershipCFRetain);
+ SIMPLE_ATTR(ObjCOwnershipMakeCollectable);
+ SIMPLE_ATTR(ObjCOwnershipRelease);
SIMPLE_ATTR(ObjCOwnershipRetain);
SIMPLE_ATTR(ObjCOwnershipReturns);
SIMPLE_ATTR(Overloadable);
case Attr::ObjCException:
case Attr::ObjCNSObject:
case Attr::ObjCOwnershipCFRelease:
- case Attr::ObjCOwnershipRelease:
case Attr::ObjCOwnershipCFRetain:
+ case Attr::ObjCOwnershipMakeCollectable:
+ case Attr::ObjCOwnershipRelease:
case Attr::ObjCOwnershipRetain:
case Attr::ObjCOwnershipReturns:
case Attr::Overloadable:
case 24:
if (!memcmp(Str, "objc_ownership_cfrelease", 24))
return AT_objc_ownership_cfrelease;
+ break;
+ case 31:
+ if (!memcmp(Str, "objc_ownership_make_collectable", 31))
+ return AT_objc_ownership_make_collectable;
break;
}
return UnknownAttribute;
default:
assert(0 && "invalid ownership attribute");
return;
+ case AttributeList::AT_objc_ownership_cfrelease:
+ name = "objc_ownership_cfrelease"; break;
+ case AttributeList::AT_objc_ownership_cfretain:
+ name = "objc_ownership_cfretain"; 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_cfrelease:
- name = "objc_ownership_cfrelease"; break;
case AttributeList::AT_objc_ownership_retain:
name = "objc_ownership_retain"; break;
- case AttributeList::AT_objc_ownership_cfretain:
- name = "objc_ownership_cfretain"; break;
};
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) << name
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:
d->addAttr(::new (S.Context) ObjCOwnershipCFRetainAttr()); 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_nothrow: HandleNothrowAttr (D, Attr, S); break;
// Checker-specific.
+ case AttributeList::AT_objc_ownership_cfrelease:
+ case AttributeList::AT_objc_ownership_cfretain:
+ case AttributeList::AT_objc_ownership_make_collectable:
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;
case AttributeList::AT_objc_ownership_returns:
HandleObjCOwnershipReturnsAttr(D, Attr, S); break;
- (void) myCFRetain:(id)__attribute__((objc_ownership_cfretain))obj;
- (void) myRelease:(id)__attribute__((objc_ownership_release))obj;
- (void) myCFRelease:(id)__attribute__((objc_ownership_cfrelease))obj;
+- (void) makeCollectable:(id)__attribute__((objc_ownership_make_collectable))obj;
@end
void test_attr_1(TestOwnershipAttr *X) {
[X myCFRetain:str];
[X myCFRelease:str];
}
+
+void test_attr_6a(TestOwnershipAttr *X) {
+ CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{leak}}
+}
+
+void test_attr_6b(TestOwnershipAttr *X) {
+ CFMutableArrayRef A = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // no-warning
+ [X makeCollectable:(id)A];
+}
+
+