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

Gábor Spaits via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 28 07:20:20 PST 2023


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

>From e885006a873e4bd8eb4618c270bac72c11446f06 Mon Sep 17 00:00:00 2001
From: Gabor Spaits <gaborspaits1 at gmail.com>
Date: Thu, 28 Dec 2023 14:17:55 +0100
Subject: [PATCH 1/2] [analyzer] Add documentation for std::variant checker

---
 clang/docs/analyzer/checkers.rst | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index 81d40395067c9a..6e8052a0afacf8 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.

>From 67e647998a6a5b3e135c4fc760f545e73ad6b04c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A1bor=20Spaits?=
 <48805437+spaits at users.noreply.github.com>
Date: Thu, 28 Dec 2023 16:20:14 +0100
Subject: [PATCH 2/2] Update clang/docs/analyzer/checkers.rst

Co-authored-by: whisperity <whisperity at gmail.com>
---
 clang/docs/analyzer/checkers.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index 6e8052a0afacf8..8e6029406202bf 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -2103,7 +2103,7 @@ Check if the active value accessed in an ``std::variant`` instance.
 .. code-block:: cpp
 
  void test() {
-   std::variant <int, char> v = 25;
+   std::variant<int, char> v = 25;
    char c = stg::get<char>(v); // warn
  }
 



More information about the cfe-commits mailing list