Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion clang/docs/analyzer/user-docs/Annotations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ Use this attribute to mark functions that take ownership of memory and will deal

void __attribute((ownership_holds(malloc, 2))) store_in_table(int key, record_t *val);

The annotations ``ownership_takes`` and ``ownership_holds`` both prevent memory leak reports (concerning the specified parameter); the difference between them is that using taken memory is a use-after-free error, while using held memory is assumed to be legitimate.
The annotations ``ownership_takes`` and ``ownership_holds`` both prevent memory leak reports (concerning the specified parameter); the difference between them is that using taken memory is a use-after-free error, while using held memory is assumed to be legitimate. However, releasing the held memory or passing it to another holding call is reported by the analyzer as an "attempt to release non-owned memory".


Mac OS X API Annotations
________________________
Expand Down
4 changes: 3 additions & 1 deletion clang/include/clang/Basic/AttrDocs.td
Original file line number Diff line number Diff line change
Expand Up @@ -1663,7 +1663,9 @@ safely deallocated with the standard ``free()``.
The annotations ``ownership_takes`` and ``ownership_holds`` both prevent memory
leak reports (concerning the specified parameter); the difference between them
is that using taken memory is a use-after-free error, while using held memory
is assumed to be legitimate.
is assumed to be legitimate. However, releasing the held memory or passing it
to another holding call is reported by the analyzer as an "attempt to release
non-owned memory".

Example:

Expand Down