[clang] 56c5a6b - [NFC][analyzer][docs] Crosslink MallocChecker's ownership attributes (#121939)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 7 08:08:24 PST 2025
Author: Kristóf Umann
Date: 2025-01-07T17:08:21+01:00
New Revision: 56c5a6ba836065a6e3be9d04e2c64aa8a758a3f4
URL: https://github.com/llvm/llvm-project/commit/56c5a6ba836065a6e3be9d04e2c64aa8a758a3f4
DIFF: https://github.com/llvm/llvm-project/commit/56c5a6ba836065a6e3be9d04e2c64aa8a758a3f4.diff
LOG: [NFC][analyzer][docs] Crosslink MallocChecker's ownership attributes (#121939)
Forgot to mention these in the checker docs.
Added:
Modified:
clang/docs/analyzer/checkers.rst
clang/include/clang/Basic/AttrDocs.td
Removed:
################################################################################
diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index 29d5e1f92a69c2..e093b2d672a74e 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -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
@@ -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() {
@@ -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) {
@@ -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
@@ -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() {
@@ -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
diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td
index ba581e02542fc6..b8d702e41aa0bb 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -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::
More information about the cfe-commits
mailing list