aboutsummaryrefslogtreecommitdiff
path: root/clang/include
diff options
context:
space:
mode:
Diffstat (limited to 'clang/include')
-rw-r--r--clang/include/clang/Basic/Attr.td16
-rw-r--r--clang/include/clang/Basic/AttrDocs.td15
-rw-r--r--clang/include/clang/Basic/DiagnosticSemaKinds.td2
3 files changed, 30 insertions, 3 deletions
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index 311cf943dfab..1fe1dd39948a 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -841,13 +841,25 @@ def OSConsumed : InheritableParamAttr {
def OSReturnsRetained : InheritableAttr {
let Spellings = [Clang<"os_returns_retained">];
- let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty]>;
+ let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty, ParmVar]>;
let Documentation = [RetainBehaviorDocs];
}
def OSReturnsNotRetained : InheritableAttr {
let Spellings = [Clang<"os_returns_not_retained">];
- let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty]>;
+ let Subjects = SubjectList<[Function, ObjCMethod, ObjCProperty, ParmVar]>;
+ let Documentation = [RetainBehaviorDocs];
+}
+
+def OSReturnsRetainedOnZero : InheritableAttr {
+ let Spellings = [Clang<"os_returns_retained_on_zero">];
+ let Subjects = SubjectList<[ParmVar]>;
+ let Documentation = [RetainBehaviorDocs];
+}
+
+def OSReturnsRetainedOnNonZero : InheritableAttr {
+ let Spellings = [Clang<"os_returns_retained_on_non_zero">];
+ let Subjects = SubjectList<[ParmVar]>;
let Documentation = [RetainBehaviorDocs];
}
diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td
index aae2d1ddfc9e..5773a92c9c15 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -888,6 +888,21 @@ Similar to ``__attribute__((ns_consumes_self))``,
``__attribute__((os_consumes_this))`` specifies that the method call consumes
the reference to "this" (e.g., when attaching it to a different object supplied
as a parameter).
+Out parameters (parameters the function is meant to write into,
+either via pointers-to-pointers or references-to-pointers)
+may be annotated with ``__attribute__((os_returns_retained))``
+or ``__attribute__((os_returns_not_retained))`` which specifies that the object
+written into the out parameter should (or respectively should not) be released
+after use.
+Since often out parameters may or may not be written depending on the exit
+code of the function,
+annotations ``__attribute__((os_returns_retained_on_zero))``
+and ``__attribute__((os_returns_retained_on_non_zero))`` specify that
+an out parameter at ``+1`` is written if and only if the function returns a zero
+(respectively non-zero) error code.
+Observe that return-code-dependent out parameter annotations are only
+available for retained out parameters, as non-retained object do not have to be
+released by the callee.
These attributes are only used by the Clang Static Analyzer.
The family of attributes ``X_returns_X_retained`` can be added to functions,
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 2f77773ac802..57c3abd04899 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3425,7 +3425,7 @@ def err_ns_attribute_wrong_parameter_type : Error<
"%select{Objective-C object|pointer|pointer-to-CF-pointer}1 parameters">;
def warn_ns_attribute_wrong_parameter_type : Warning<
"%0 attribute only applies to "
- "%select{Objective-C object|pointer|pointer-to-CF-pointer}1 parameters">,
+ "%select{Objective-C object|pointer|pointer-to-CF-pointer|pointer/reference-to-OSObject-pointer}1 parameters">,
InGroup<IgnoredAttributes>;
def warn_objc_requires_super_protocol : Warning<
"%0 attribute cannot be applied to %select{methods in protocols|dealloc}1">,