diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index e21ec78a1e8a7..3c08d1808b0e7 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -1072,6 +1072,7 @@ New features - Added a new experimental checker ``alpha.core.StdVariant`` to detect variant accesses via wrong alternatives. + `Documentation `__. (`#66481 `_) - Added a new experimental checker ``alpha.cplusplus.ArrayDelete`` to detect diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst index 64a4752695f11..bb637cf1b8007 100644 --- a/clang/docs/analyzer/checkers.rst +++ b/clang/docs/analyzer/checkers.rst @@ -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 v = 25; + char c = stg::get(v); // warn: "int" is the active alternative + } + .. _alpha-core-TestAfterDivZero: alpha.core.TestAfterDivZero (C)