[clang] [NFC][analyzer][docs] Crosslink MallocChecker's ownership attributes (PR #121939)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 7 06:20:06 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-static-analyzer-1
Author: Kristóf Umann (Szelethus)
<details>
<summary>Changes</summary>
Forgot to mention these in the checker docs.
---
Full diff: https://github.com/llvm/llvm-project/pull/121939.diff
2 Files Affected:
- (modified) clang/docs/analyzer/checkers.rst (+18)
- (modified) clang/include/clang/Basic/AttrDocs.td (+1)
``````````diff
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::
``````````
</details>
https://github.com/llvm/llvm-project/pull/121939
More information about the cfe-commits
mailing list