From 87494017b8965ecc89351c8330fd4265d402d89b Mon Sep 17 00:00:00 2001 From: John McCall Date: Fri, 18 Mar 2011 03:51:49 +0000 Subject: [PATCH] Improve the documentation for some of the analyzer attributes I added a while back. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127866 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/LanguageExtensions.html | 52 +++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/docs/LanguageExtensions.html b/docs/LanguageExtensions.html index 6bde981788..99c7d013ca 100644 --- a/docs/LanguageExtensions.html +++ b/docs/LanguageExtensions.html @@ -62,11 +62,7 @@ td {
  • X86/X86-64 Language Extensions
  • -
  • Static Analysis-Specific Extensions - -
  • +
  • Static Analysis-Specific Extensions
  • @@ -760,11 +756,7 @@ are used by the path-sensitive static analyzer engine that is part of Clang's Analysis library.

    - -

    Analyzer Attributes

    - - -

    analyzer_noreturn

    +

    The analyzer_noreturn attribute

    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).

    + +

    The objc_method_family attribute

    + +

    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.

    -

    Objective-C retaining behavior attributes

    +

    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).

    + +

    Objective-C retaining behavior attributes

    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.

    + -- 2.40.0