Skip to content

Commit b271420

Browse files
committed
[analyzer] Add documentation for std::variant checker
1 parent 0487377 commit b271420

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-stdvariantchecker-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
2111+
}
2112+
20982113
.. _alpha-core-TestAfterDivZero:
20992114
21002115
alpha.core.TestAfterDivZero (C)

0 commit comments

Comments
 (0)