[clang] [analyzer] Add documentation for std::variant checker (PR #76501)
Balazs Benics via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 28 07:51:25 PST 2023
================
@@ -2097,6 +2097,21 @@ This checker is a part of ``core.StackAddressEscape``, but is temporarily disabl
.. _alpha-core-TestAfterDivZero:
+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
+ }
+
+.. _alpha-core-StdVariant:
----------------
steakhal wrote:
This xref label should be right before the `""""...` subsection introducer. It will behave as a link target in the TOC.
This is definitely not the right place here.
Note that the `_alpha-core-TestAfterDivZero:` label would currently refer to this section.
https://github.com/llvm/llvm-project/pull/76501
More information about the cfe-commits
mailing list