Skip to content

Commit 84da033

Browse files
committed
Expand on allocation type
1 parent 00c2349 commit 84da033

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

clang/include/clang/Basic/AttrDocs.td

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,8 +1407,17 @@ These attributes are used by the Clang Static Analyzer's dynamic memory modeling
14071407
facilities to mark custom allocating/deallocating functions.
14081408

14091409
All 3 attributes' first parameter of type string is the type of the allocation:
1410-
``malloc``, ``new``, etc. to allow for catching mismatched deallocation bugs to
1411-
be found.
1410+
``malloc``, ``new``, etc. to allow for catching :ref:`mismatched deallocation
1411+
<unix-MismatchedDeallocator>` bugs to
1412+
be found. The allocation type can be any string, e.g. a function annotated with
1413+
returning a piece of memory of type ``lasagna`` but freed with a function
1414+
annoteted to release ``cheese`` typed memory will result in mismatched
1415+
deallocation warning.
1416+
1417+
The (currently) only allocation type having special meaning is ``malloc`` --
1418+
the Clang Static Analyzer makes sure that allocating functions annotated with
1419+
``malloc`` are treated like they used the standard ``malloc()``, and can be
1420+
safely deallocated with the standard ``free()``.
14121421

14131422
* Use ``ownership_returns`` to mark a function as an allocating function. Takes
14141423
1 parameter to denote the allocation type.
@@ -1419,6 +1428,7 @@ be found.
14191428
piece of memory and will free it at some unspecified point in the future. Like
14201429
``ownership_takes``, this takes 2 parameters: the allocation type, and the
14211430
index of the parameter whose ownership will be taken over (counting from 1).
1431+
14221432
The annotations ``ownership_takes`` and ``ownership_holds`` both prevent memory
14231433
leak reports (concerning the specified argument); the difference between them
14241434
is that using taken memory is a use-after-free error, while using held memory

0 commit comments

Comments
 (0)