Skip to content

Commit 1d2fab7

Browse files
spaitssteakhalwhisperityNagyDonat
authored
[analyzer] Add documentation for std::variant checker (#76501)
Add a short documentation for `StdVariantChecker`. --------- Co-authored-by: Balazs Benics <[email protected]> Co-authored-by: whisperity <[email protected]> Co-authored-by: DonatNagyE <[email protected]>
1 parent 9e439a3 commit 1d2fab7

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,7 @@ New features
10721072

10731073
- Added a new experimental checker ``alpha.core.StdVariant`` to detect variant
10741074
accesses via wrong alternatives.
1075+
`Documentation <https://clang.llvm.org/docs/analyzer/checkers.html#alpha-core-stdvariant-c>`__.
10751076
(`#66481 <https://github.com/llvm/llvm-project/pull/66481>`_)
10761077

10771078
- Added a new experimental checker ``alpha.cplusplus.ArrayDelete`` to detect

clang/docs/analyzer/checkers.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,6 +2095,21 @@ This checker is a part of ``core.StackAddressEscape``, but is temporarily disabl
20952095
// returned block
20962096
}
20972097
2098+
.. _alpha-core-StdVariant:
2099+
2100+
alpha.core.StdVariant (C++)
2101+
"""""""""""""""""""""""""""
2102+
Check if a value of active type is retrieved from an ``std::variant`` instance with ``std::get``.
2103+
In case of bad variant type access (the accessed type differs from the active type)
2104+
a warning is emitted. Currently, this checker does not take exception handling into account.
2105+
2106+
.. code-block:: cpp
2107+
2108+
void test() {
2109+
std::variant<int, char> v = 25;
2110+
char c = stg::get<char>(v); // warn: "int" is the active alternative
2111+
}
2112+
20982113
.. _alpha-core-TestAfterDivZero:
20992114
21002115
alpha.core.TestAfterDivZero (C)

0 commit comments

Comments
 (0)