[analyzer] Add documentation for std::variant checker (#76501)

Add a short documentation for `StdVariantChecker`.

---------

Co-authored-by: Balazs Benics <benicsbalazs@gmail.com>
Co-authored-by: whisperity <whisperity@gmail.com>
Co-authored-by: DonatNagyE <donat.nagy@ericsson.com>
This commit is contained in:
Gábor Spaits 2023-12-28 22:19:51 +01:00 committed by GitHub
parent 9e439a3539
commit 1d2fab74af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -1072,6 +1072,7 @@ New features
- Added a new experimental checker ``alpha.core.StdVariant`` to detect variant
accesses via wrong alternatives.
`Documentation <https://clang.llvm.org/docs/analyzer/checkers.html#alpha-core-stdvariant-c>`__.
(`#66481 <https://github.com/llvm/llvm-project/pull/66481>`_)
- Added a new experimental checker ``alpha.cplusplus.ArrayDelete`` to detect

View File

@ -2095,6 +2095,21 @@ This checker is a part of ``core.StackAddressEscape``, but is temporarily disabl
// returned block
}
.. _alpha-core-StdVariant:
alpha.core.StdVariant (C++)
"""""""""""""""""""""""""""
Check if a value of active type is retrieved from an ``std::variant`` instance with ``std::get``.
In case of bad variant type access (the accessed type differs from the active type)
a warning is emitted. Currently, this checker does not take exception handling into account.
.. code-block:: cpp
void test() {
std::variant<int, char> v = 25;
char c = stg::get<char>(v); // warn: "int" is the active alternative
}
.. _alpha-core-TestAfterDivZero:
alpha.core.TestAfterDivZero (C)