[clang-tools-extra] [clang-tidy][NFC][doc] improve "options" sections of `bugprone-` and `modernize-` checks (PR #133525)
Baranov Victor via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 30 09:55:31 PDT 2025
https://github.com/vbvictor updated https://github.com/llvm/llvm-project/pull/133525
>From 9b88fc69e06d08fd06b60af24b5a9c12749185ef Mon Sep 17 00:00:00 2001
From: Victor Baranov <bar.victor.2002 at gmail.com>
Date: Sat, 29 Mar 2025 00:46:22 +0300
Subject: [PATCH 1/3] improve docs options of `bugprone-` and `modernize-`
checks
---
.../docs/clang-tidy/checks/bugprone/assert-side-effect.rst | 1 +
.../checks/bugprone/capturing-this-in-member-variable.rst | 3 +++
.../docs/clang-tidy/checks/bugprone/signed-char-misuse.rst | 5 ++++-
.../clang-tidy/checks/bugprone/suspicious-enum-usage.rst | 1 +
.../checks/bugprone/suspicious-stringview-data-usage.rst | 3 +++
.../clang-tidy/checks/bugprone/too-small-loop-variable.rst | 3 +++
.../checks/bugprone/unhandled-self-assignment.rst | 3 +++
.../checks/bugprone/unintended-char-ostream-output.rst | 3 +++
.../docs/clang-tidy/checks/modernize/avoid-bind.rst | 3 ++-
.../docs/clang-tidy/checks/modernize/avoid-c-arrays.rst | 3 +++
.../docs/clang-tidy/checks/modernize/loop-convert.rst | 3 +++
.../docs/clang-tidy/checks/modernize/make-shared.rst | 2 +-
.../docs/clang-tidy/checks/modernize/make-unique.rst | 2 +-
.../docs/clang-tidy/checks/modernize/raw-string-literal.rst | 3 +++
.../docs/clang-tidy/checks/modernize/use-emplace.rst | 6 +++++-
15 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/assert-side-effect.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/assert-side-effect.rst
index 1355afae92e4f..3ca712b958d04 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/assert-side-effect.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/assert-side-effect.rst
@@ -15,6 +15,7 @@ Options
.. option:: AssertMacros
A comma-separated list of the names of assert macros to be checked.
+ Default is `assert,NSAssert,NSCAssert`.
.. option:: CheckFunctionCalls
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/capturing-this-in-member-variable.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/capturing-this-in-member-variable.rst
index bb75e9239d9b5..b09d7d5fce959 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/capturing-this-in-member-variable.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/capturing-this-in-member-variable.rst
@@ -32,6 +32,9 @@ Possible fixes:
object types.
- passing ``this`` pointer as parameter
+Options
+-------
+
.. option:: FunctionWrapperTypes
A semicolon-separated list of names of types. Used to specify function
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/signed-char-misuse.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/signed-char-misuse.rst
index 72860e8cf2a1d..4edbad5eac81b 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/signed-char-misuse.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/signed-char-misuse.rst
@@ -104,13 +104,16 @@ so both arguments will have the same type.
return false;
}
+Options
+-------
+
.. option:: CharTypdefsToIgnore
A semicolon-separated list of typedef names. In this list, we can list
typedefs for ``char`` or ``signed char``, which will be ignored by the
check. This is useful when a typedef introduces an integer alias like
``sal_Int8`` or ``int8_t``. In this case, human misinterpretation is not
- an issue.
+ an issue. Default is an empty string.
.. option:: DiagnoseSignedUnsignedCharComparisons
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/suspicious-enum-usage.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/suspicious-enum-usage.rst
index e87172414a23e..94f29ee11ee39 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/suspicious-enum-usage.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/suspicious-enum-usage.rst
@@ -71,6 +71,7 @@ Examples:
Options
-------
+
.. option:: StrictMode
Default value: 0.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/suspicious-stringview-data-usage.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/suspicious-stringview-data-usage.rst
index 9b38d83601810..de10da21e8442 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/suspicious-stringview-data-usage.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/suspicious-stringview-data-usage.rst
@@ -43,6 +43,9 @@ lead to a compilation error due to the explicit nature of the ``std::string``
constructor. Consequently, developers might opt for ``sv.data()`` to resolve the
compilation error, albeit introducing potential hazards as discussed.
+Options
+-------
+
.. option:: StringViewTypes
Option allows users to specify custom string view-like types for analysis. It
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/too-small-loop-variable.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/too-small-loop-variable.rst
index 2c3ded952aa02..077abf0af6880 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/too-small-loop-variable.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/too-small-loop-variable.rst
@@ -32,6 +32,9 @@ It's recommended to enable the compiler warning
`-Wtautological-constant-out-of-range-compare` as well, since check does not
inspect compile-time constant loop boundaries to avoid overlaps with the warning.
+Options
+-------
+
.. option:: MagnitudeBitsUpperLimit
Upper limit for the magnitude bits of the loop variable. If it's set the check
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/unhandled-self-assignment.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/unhandled-self-assignment.rst
index d3cdd5a12fdca..3a6245d2fe35b 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/unhandled-self-assignment.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/unhandled-self-assignment.rst
@@ -118,6 +118,9 @@ temporary object into ``this`` (needs a move assignment operator):
}
};
+Options
+-------
+
.. option:: WarnOnlyIfThisHasSuspiciousField
When `true`, the check will warn only if the container class of the copy
diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone/unintended-char-ostream-output.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone/unintended-char-ostream-output.rst
index ea1051847129b..95d02b3e2ddda 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/unintended-char-ostream-output.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/unintended-char-ostream-output.rst
@@ -39,6 +39,9 @@ Or cast to char to explicitly indicate that output should be a character.
std::cout << static_cast<char>(v);
+Options
+-------
+
.. option:: CastTypeName
When `CastTypeName` is specified, the fix-it will use `CastTypeName` as the
diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-bind.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-bind.rst
index 10374daecb660..64e7e95db8800 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-bind.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-bind.rst
@@ -50,8 +50,9 @@ Options
of every placeholder parameter list. Without this, it is possible for a fix-it
to perform an incorrect transformation in the case where the result of the ``bind``
is used in the context of a type erased functor such as ``std::function`` which
- allows mismatched arguments. For example:
+ allows mismatched arguments. Default is is `false`.
+For example:
.. code-block:: c++
diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-c-arrays.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-c-arrays.rst
index 6a386ecd0fd4b..b7a87bf23967b 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-c-arrays.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-c-arrays.rst
@@ -62,6 +62,9 @@ Similarly, the ``main()`` function is ignored. Its second and third parameters
can be either ``char* argv[]`` or ``char** argv``, but cannot be
``std::array<>``.
+Options
+-------
+
.. option:: AllowStringArrays
When set to `true` (default is `false`), variables of character array type
diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/loop-convert.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/loop-convert.rst
index 0c423edca1822..3f4783e220501 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/modernize/loop-convert.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/loop-convert.rst
@@ -140,6 +140,9 @@ however the check can be configured to work without C++20 by specifying a
function to reverse a range and optionally the header file where that function
lives.
+Options
+-------
+
.. option:: UseCxx20ReverseRanges
When set to true convert loops when in C++20 or later mode using
diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/make-shared.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/make-shared.rst
index 9c1fceaa06000..1a8698d4366c9 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/modernize/make-shared.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/make-shared.rst
@@ -53,4 +53,4 @@ Options
If set to non-zero, the check does not suggest edits that will transform
default initialization into value initialization, as this can cause
- performance regressions. Default is `1`.
+ performance regressions. Default is `true`.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/make-unique.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/make-unique.rst
index cd474d352bac0..a7fb17a4d6937 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/modernize/make-unique.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/make-unique.rst
@@ -53,4 +53,4 @@ Options
If set to non-zero, the check does not suggest edits that will transform
default initialization into value initialization, as this can cause
- performance regressions. Default is `1`.
+ performance regressions. Default is `true`.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/raw-string-literal.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/raw-string-literal.rst
index 6d7589a0011bb..66e50e80fa70b 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/modernize/raw-string-literal.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/raw-string-literal.rst
@@ -45,6 +45,9 @@ An escaped horizontal tab, form feed, or vertical tab prevents the string
literal from being converted. The presence of a horizontal tab, form feed or
vertical tab in source code is not visually obvious.
+Options
+-------
+
.. option:: DelimiterStem
Custom delimiter to escape characters in raw string literals. It is used in
diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-emplace.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-emplace.rst
index f61b93aac7c76..61eaf5cf43b1c 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-emplace.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-emplace.rst
@@ -163,7 +163,11 @@ Options
Semicolon-separated list of containers without their template parameters
and some ``emplace``-like method of the container. Example:
``vector::emplace_back``. Those methods will be checked for improper use and
- the check will report when a temporary is unnecessarily created.
+ the check will report when a temporary is unnecessarily created. Default
+ containers with their ``emplace``-like methods are ``vector``, ``deque``,
+ ``forward_list``, ``list``, ``set``, ``map``, ``multiset``, ``multimap``,
+ ``unordered_set``, ``unordered_map``, ``unordered_multiset``,
+ ``unordered_multimap``, ``stack``, ``queue``, ``priority_queue``.
Example
^^^^^^^
>From a9f7d9b5a49cf71f00294118ac958df838804e5a Mon Sep 17 00:00:00 2001
From: Victor Baranov <bar.victor.2002 at gmail.com>
Date: Sun, 30 Mar 2025 01:09:39 +0300
Subject: [PATCH 2/3] fix: review comments
---
.../docs/clang-tidy/checks/modernize/make-shared.rst | 2 +-
.../docs/clang-tidy/checks/modernize/make-unique.rst | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/make-shared.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/make-shared.rst
index 1a8698d4366c9..982138fc5e781 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/modernize/make-shared.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/make-shared.rst
@@ -51,6 +51,6 @@ Options
.. option:: IgnoreDefaultInitialization
- If set to non-zero, the check does not suggest edits that will transform
+ If set to `false`, the check does not suggest edits that will transform
default initialization into value initialization, as this can cause
performance regressions. Default is `true`.
diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/make-unique.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/make-unique.rst
index a7fb17a4d6937..1aaa8701cd0f1 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/modernize/make-unique.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/make-unique.rst
@@ -51,6 +51,6 @@ Options
.. option:: IgnoreDefaultInitialization
- If set to non-zero, the check does not suggest edits that will transform
+ If set to `false`, the check does not suggest edits that will transform
default initialization into value initialization, as this can cause
performance regressions. Default is `true`.
>From 880c9a209ebd7106b4ed41cf1cc10d809efa3e1d Mon Sep 17 00:00:00 2001
From: Victor Baranov <bar.victor.2002 at gmail.com>
Date: Sun, 30 Mar 2025 19:55:17 +0300
Subject: [PATCH 3/3] fix: use-emplace.rst `EmplacyFunctions` option
---
.../docs/clang-tidy/checks/modernize/use-emplace.rst | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-emplace.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-emplace.rst
index 61eaf5cf43b1c..e020ece296475 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-emplace.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-emplace.rst
@@ -163,11 +163,8 @@ Options
Semicolon-separated list of containers without their template parameters
and some ``emplace``-like method of the container. Example:
``vector::emplace_back``. Those methods will be checked for improper use and
- the check will report when a temporary is unnecessarily created. Default
- containers with their ``emplace``-like methods are ``vector``, ``deque``,
- ``forward_list``, ``list``, ``set``, ``map``, ``multiset``, ``multimap``,
- ``unordered_set``, ``unordered_map``, ``unordered_multiset``,
- ``unordered_multimap``, ``stack``, ``queue``, ``priority_queue``.
+ the check will report when a temporary is unnecessarily created. All STL
+ containers with such member functions are supported by default.
Example
^^^^^^^
More information about the cfe-commits
mailing list