Skip to content

Commit

Permalink
[NFC][analyzer][docs] Crosslink MallocChecker's ownership attributes (#…
Browse files Browse the repository at this point in the history
…121939)

Forgot to mention these in the checker docs.
  • Loading branch information
Szelethus authored Jan 7, 2025
1 parent 619a5d3 commit 56c5a6b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions clang/docs/analyzer/checkers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,9 @@ cplusplus.NewDelete (C++)
"""""""""""""""""""""""""
Check for double-free and use-after-free problems. Traces memory managed by new/delete.
Custom allocation/deallocation functions can be defined using
:ref:`ownership attributes<analyzer-ownership-attrs>`.
.. literalinclude:: checkers/newdelete_example.cpp
:language: cpp
Expand All @@ -485,6 +488,9 @@ cplusplus.NewDeleteLeaks (C++)
""""""""""""""""""""""""""""""
Check for memory leaks. Traces memory managed by new/delete.
Custom allocation/deallocation functions can be defined using
:ref:`ownership attributes<analyzer-ownership-attrs>`.
.. code-block:: cpp
void test() {
Expand Down Expand Up @@ -1263,6 +1269,9 @@ You can silence this warning either by bound checking the ``size`` parameter, or
by explicitly marking the ``size`` parameter as sanitized. See the
:ref:`optin-taint-GenericTaint` checker for an example.
Custom allocation/deallocation functions can be defined using
:ref:`ownership attributes<analyzer-ownership-attrs>`.
.. code-block:: c
void vulnerable(void) {
Expand Down Expand Up @@ -1857,6 +1866,9 @@ unix.Malloc (C)
"""""""""""""""
Check for memory leaks, double free, and use-after-free problems. Traces memory managed by malloc()/free().
Custom allocation/deallocation functions can be defined using
:ref:`ownership attributes<analyzer-ownership-attrs>`.
.. literalinclude:: checkers/unix_malloc_example.c
:language: c
Expand All @@ -1866,6 +1878,9 @@ unix.MallocSizeof (C)
"""""""""""""""""""""
Check for dubious ``malloc`` arguments involving ``sizeof``.
Custom allocation/deallocation functions can be defined using
:ref:`ownership attributes<analyzer-ownership-attrs>`.
.. code-block:: c
void test() {
Expand All @@ -1881,6 +1896,9 @@ unix.MismatchedDeallocator (C, C++)
"""""""""""""""""""""""""""""""""""
Check for mismatched deallocators.
Custom allocation/deallocation functions can be defined using
:ref:`ownership attributes<analyzer-ownership-attrs>`.
.. literalinclude:: checkers/mismatched_deallocator_example.cpp
:language: c
Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/Basic/AttrDocs.td
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,7 @@ def OwnershipDocs : Documentation {
let Heading = "ownership_holds, ownership_returns, ownership_takes (Clang "
"Static Analyzer)";
let Category = DocCatFunction;
let Label = "analyzer-ownership-attrs";
let Content = [{

.. note::
Expand Down

0 comments on commit 56c5a6b

Please sign in to comment.