From: John McCall
Clang's static analysis engine understands the standard noreturn attribute. This attribute, which is typically affixed to a function prototype, @@ -792,16 +784,47 @@ placed at the end of function prototypes:
void foo() __attribute__((analyzer_noreturn)); -Query for this feature with __has_feature(attribute_analyzer_noreturn).
+Query for this feature with +__has_attribute(analyzer_noreturn).
+ +Many methods in Objective-C have conventional meanings determined
+by their selectors. For the purposes of static analysis, it is
+sometimes useful to be able to mark a method as having a particular
+conventional meaning despite not having the right selector, or as not
+having the conventional meaning that its selector would suggest.
+For these use cases, we provide an attribute to specifically describe
+the method family
that a method belongs to.
Usage: __attribute__((objc_method_family(X))), +where X is one of none, alloc, copy, +init, mutableCopy, or new. This attribute +can only be placed at the end of a method declaration:
+ ++ - (NSString*) initMyStringValue __attribute__((objc_method_family(none))); ++ +
Users who do not wish to change the conventional meaning of a +method, and who merely want to document its non-standard retain and +release semantics, should use the +retaining behavior attributes +described below.
+ +Query for this feature with +__has_attribute(objc_method_family).
+ +In Objective-C, functions and methods are generally assumed to take and return objects with +0 retain counts, with some exceptions for special methods like +alloc and init. However, there are exceptions, and so Clang provides attributes to allow these exceptions to be documented, which helps the analyzer find leaks (and -ignore non-leaks).
+ignore non-leaks). Some exceptions may be better described using +the objc_method_family +attribute instead.Usage: The ns_returns_retained, ns_returns_not_retained, ns_returns_autoreleased, cf_returns_retained, @@ -840,6 +863,9 @@ balance in some way.
- (void) baz: (id) __attribute__((ns_consumed)) x; +Query for these features with __has_attribute(ns_consumed), +__has_attribute(ns_returns_retained), etc.
+