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

via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 28 05:20:08 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Gábor Spaits (spaits)

<details>
<summary>Changes</summary>

Add a short documentation for `StdVariantChecker`.

---
Full diff: https://github.com/llvm/llvm-project/pull/76501.diff


1 Files Affected:

- (modified) clang/docs/analyzer/checkers.rst (+12) 


``````````diff
diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index 81d40395067c9a..1e5ba013f85d67 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -2097,6 +2097,18 @@ This checker is a part of ``core.StackAddressEscape``, but is temporarily disabl
 
 .. _alpha-core-TestAfterDivZero:
 
+alpha.core.StdVariant (C++)
+"""""""""""""""""""""""
+Check if the active value accessed in an ``std::variant`` instance.
+.. code-block:: cpp
+
+ void test() {
+   std::variant <int, char> v = 25;
+   char c = stg::get<char>(v); // warn
+ }
+
+.. _alpha-core-StdVariant:
+
 alpha.core.TestAfterDivZero (C)
 """""""""""""""""""""""""""""""
 Check for division by variable that is later compared against 0.

``````````

</details>


https://github.com/llvm/llvm-project/pull/76501


More information about the cfe-commits mailing list