Skip to content

[analyzer] Add documentation for std::variant checker #76501

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 28, 2023

Conversation

spaits
Copy link
Contributor

@spaits spaits commented Dec 28, 2023

Add a short documentation for StdVariantChecker.

@spaits spaits requested review from steakhal and NagyDonat December 28, 2023 13:19
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:static analyzer labels Dec 28, 2023
@llvmbot
Copy link
Member

llvmbot commented Dec 28, 2023

@llvm/pr-subscribers-clang-static-analyzer-1

@llvm/pr-subscribers-clang

Author: Gábor Spaits (spaits)

Changes

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 --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.

@NagyDonat
Copy link
Contributor

Note: the docs build check failed with

/home/runner/work/llvm-project/llvm-project/clang-build/tools/clang/docs/analyzer/checkers.rst:2108:Definition list ends without a blank line; unexpected unindent.

Copy link
Contributor

@NagyDonat NagyDonat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a trivial typo, otherwise LGTM.

Thanks for the update!

@spaits
Copy link
Contributor Author

spaits commented Dec 28, 2023

Added some more explanation. I will continue using "Check if" since the other descriptions that I saw stared like that (or "Check for").

Copy link
Contributor

@steakhal steakhal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also update the release notes with a link as documentation. Follow the existing patterns there.

@NagyDonat
Copy link
Contributor

Added some more explanation. I will continue using "Check if" since the other descriptions that I saw stared like that (or "Check for").

That's a good point for using "Check if".

@spaits spaits force-pushed the VariantCheckerDoc branch 3 times, most recently from e0dabac to daec813 Compare December 28, 2023 16:08
spaits and others added 4 commits December 28, 2023 17:11
@steakhal
Copy link
Contributor

let me check it again

Copy link
Contributor

@steakhal steakhal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now. Thanks.

@spaits
Copy link
Contributor Author

spaits commented Dec 28, 2023

I will merge the PR when the CI builds have finished. Thank you for reviewing.

@spaits spaits merged commit 1d2fab7 into llvm:main Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:static analyzer clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants