diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/braces-around-statements.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp/braces-around-statements.rst index 15a410e0d71cc..aef997538d331 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/hicpp/braces-around-statements.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp/braces-around-statements.rst @@ -6,6 +6,8 @@ hicpp-braces-around-statements ============================== The `hicpp-braces-around-statements` check is an alias, please see -:doc:`readability-braces-around-statements <../readability/braces-around-statements>` +:doc:`readability-braces-around-statements +<../readability/braces-around-statements>` for more information. -It enforces the `rule 6.1.1 `_. +It enforces the `rule 6.1.1 +`_. diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/explicit-conversions.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp/explicit-conversions.rst index d8c69399d6d65..6072527b28a3a 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/hicpp/explicit-conversions.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp/explicit-conversions.rst @@ -5,13 +5,21 @@ hicpp-explicit-conversions ========================== -This check is an alias for :doc:`google-explicit-constructor <../google/explicit-constructor>`. -Used to enforce parts of `rule 5.4.1 `_. -This check will enforce that constructors and conversion operators are marked `explicit`. -Other forms of casting checks are implemented in other places. -The following checks can be used to check for more forms of casting: +This check is an alias for +:doc:`google-explicit-constructor <../google/explicit-constructor>`. -- :doc:`cppcoreguidelines-pro-type-static-cast-downcast <../cppcoreguidelines/pro-type-static-cast-downcast>` -- :doc:`cppcoreguidelines-pro-type-reinterpret-cast <../cppcoreguidelines/pro-type-reinterpret-cast>` -- :doc:`cppcoreguidelines-pro-type-const-cast <../cppcoreguidelines/pro-type-const-cast>` -- :doc:`cppcoreguidelines-pro-type-cstyle-cast <../cppcoreguidelines/pro-type-cstyle-cast>` +Used to enforce parts of `rule 5.4.1 +`_. +This check will enforce that constructors and conversion operators are +marked ``explicit``. Other forms of casting checks are implemented in +other places. The following checks can be used to check for more forms +of casting: + +- :doc:`cppcoreguidelines-pro-type-static-cast-downcast + <../cppcoreguidelines/pro-type-static-cast-downcast>` +- :doc:`cppcoreguidelines-pro-type-reinterpret-cast + <../cppcoreguidelines/pro-type-reinterpret-cast>` +- :doc:`cppcoreguidelines-pro-type-const-cast + <../cppcoreguidelines/pro-type-const-cast>` +- :doc:`cppcoreguidelines-pro-type-cstyle-cast + <../cppcoreguidelines/pro-type-cstyle-cast>` diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/function-size.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp/function-size.rst index 5ccf670ed55a3..ad91c2514c97f 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/hicpp/function-size.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp/function-size.rst @@ -5,7 +5,8 @@ hicpp-function-size =================== -This check is an alias for :doc:`readability-function-size <../readability/function-size>`. +This check is an alias for +:doc:`readability-function-size <../readability/function-size>`. Useful to enforce multiple sections on function complexity. - `rule 8.2.2 `_ diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/ignored-remove-result.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp/ignored-remove-result.rst index 6ca704ae3e66c..4a89949ce45d7 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/hicpp/ignored-remove-result.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp/ignored-remove-result.rst @@ -13,7 +13,8 @@ operating over. On completion, they return an iterator to the last valid element. In the majority of cases the correct behavior is to use this result as the first operand in a call to ``std::erase``. -This check is a subset of :doc:`bugprone-unused-return-value <../bugprone/unused-return-value>` +This check is a subset of :doc:`bugprone-unused-return-value +<../bugprone/unused-return-value>` and depending on used options it can be superfluous to enable both checks. Options diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/invalid-access-moved.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp/invalid-access-moved.rst index 13184d46380cb..fd2e04a0fc711 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/hicpp/invalid-access-moved.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp/invalid-access-moved.rst @@ -5,6 +5,7 @@ hicpp-invalid-access-moved ========================== -This check is an alias for :doc:`bugprone-use-after-move <../bugprone/use-after-move>`. +This check is an alias for +:doc:`bugprone-use-after-move <../bugprone/use-after-move>`. Implements parts of the `rule 8.4.1 `_ to check if moved-from objects are accessed. diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/move-const-arg.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp/move-const-arg.rst index b43c23344f2e2..7af8401602328 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/hicpp/move-const-arg.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp/move-const-arg.rst @@ -6,5 +6,6 @@ hicpp-move-const-arg ==================== The `hicpp-move-const-arg` check is an alias, please see -:doc:`performance-move-const-arg <../performance/move-const-arg>` for more information. +:doc:`performance-move-const-arg <../performance/move-const-arg>` +for more information. It enforces the `rule 17.3.1 `_. diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/multiway-paths-covered.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp/multiway-paths-covered.rst index 983de34e36731..f164f4c0b2f48 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/hicpp/multiway-paths-covered.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp/multiway-paths-covered.rst @@ -4,15 +4,16 @@ hicpp-multiway-paths-covered ============================ This check discovers situations where code paths are not fully-covered. -It furthermore suggests using ``if`` instead of ``switch`` if the code will be more clear. +It furthermore suggests using ``if`` instead of ``switch`` if the code +will be more clear. The `rule 6.1.2 `_ and `rule 6.1.4 `_ of the High Integrity C++ Coding Standard are enforced. -``if-else if`` chains that miss a final ``else`` branch might lead to unexpected -program execution and be the result of a logical error. -If the missing ``else`` branch is intended you can leave it empty with a clarifying -comment. +``if-else if`` chains that miss a final ``else`` branch might lead to +unexpected program execution and be the result of a logical error. +If the missing ``else`` branch is intended you can leave it empty with +a clarifying comment. This warning can be noisy on some code bases, so it is disabled by default. .. code-block:: c++ @@ -28,7 +29,8 @@ This warning can be noisy on some code bases, so it is disabled by default. // ... } -Similar arguments hold for ``switch`` statements which do not cover all possible code paths. +Similar arguments hold for ``switch`` statements which do not cover all +possible code paths. .. code-block:: c++ diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/named-parameter.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp/named-parameter.rst index 7f894b11b6b60..4506596946ead 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/hicpp/named-parameter.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp/named-parameter.rst @@ -5,6 +5,7 @@ hicpp-named-parameter ===================== -This check is an alias for :doc:`readability-named-parameter <../readability/named-parameter>`. +This check is an alias for :doc:`readability-named-parameter +<../readability/named-parameter>`. Implements `rule 8.2.1 `_. diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/no-array-decay.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp/no-array-decay.rst index 85b93cb99a18d..715a1b7638e8b 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/hicpp/no-array-decay.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp/no-array-decay.rst @@ -6,6 +6,7 @@ hicpp-no-array-decay ==================== The `hicpp-no-array-decay` check is an alias, please see -:doc:`cppcoreguidelines-pro-bounds-array-to-pointer-decay <../cppcoreguidelines/pro-bounds-array-to-pointer-decay>` +:doc:`cppcoreguidelines-pro-bounds-array-to-pointer-decay +<../cppcoreguidelines/pro-bounds-array-to-pointer-decay>` for more information. It enforces the `rule 4.1.1 `_. diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp/uppercase-literal-suffix.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp/uppercase-literal-suffix.rst index 994363accc8c6..34b9f255a44c8 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/hicpp/uppercase-literal-suffix.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp/uppercase-literal-suffix.rst @@ -6,7 +6,8 @@ hicpp-uppercase-literal-suffix ============================== The hicpp-uppercase-literal-suffix check is an alias, please see -:doc:`readability-uppercase-literal-suffix <../readability/uppercase-literal-suffix>` for more information. +:doc:`readability-uppercase-literal-suffix +<../readability/uppercase-literal-suffix>` for more information. Partially implements `rule 4.2.1 `_ to ensure that the ``U`` suffix is writeln properly. diff --git a/clang-tools-extra/docs/clang-tidy/checks/linuxkernel/must-check-errs.rst b/clang-tools-extra/docs/clang-tidy/checks/linuxkernel/must-check-errs.rst index cef5a70db309e..6a4b743665964 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/linuxkernel/must-check-errs.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/linuxkernel/must-check-errs.rst @@ -4,8 +4,8 @@ linuxkernel-must-check-errs =========================== Checks Linux kernel code to see if it uses the results from the functions in -``linux/err.h``. Also checks to see if code uses the results from functions that -directly return a value from one of these error functions. +``linux/err.h``. Also checks to see if code uses the results from functions +that directly return a value from one of these error functions. This is important in the Linux kernel because ``ERR_PTR``, ``PTR_ERR``, ``IS_ERR``, ``IS_ERR_OR_NULL``, ``ERR_CAST``, and ``PTR_ERR_OR_ZERO`` return diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst b/clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst index 18ec10be347dc..01f3b75fc1ffa 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/misc/const-correctness.rst @@ -4,14 +4,14 @@ misc-const-correctness ====================== This check implements detection of local variables which could be declared as -``const`` but are not. Declaring variables as ``const`` is required or recommended by many -coding guidelines, such as: +``const`` but are not. Declaring variables as ``const`` is required or +recommended by many coding guidelines, such as: `ES.25 `_ from the C++ Core Guidelines. -Please note that this check's analysis is type-based only. Variables that are not modified -but used to create a non-const handle that might escape the scope are not diagnosed -as potential ``const``. +Please note that this check's analysis is type-based only. Variables that are +not modified but used to create a non-const handle that might escape the scope +are not diagnosed as potential ``const``. .. code-block:: c++ @@ -44,8 +44,8 @@ The check can analyze values, pointers and references and pointees: int const*const pointer_variable = &potential_const_int; // After transformation, both pointer itself and pointee are supported. int last_copy = *pointer_variable; -The automatic code transformation is only applied to variables that are declared in single -declarations. You may want to prepare your code base with +The automatic code transformation is only applied to variables that are +declared in single declarations. You may want to prepare your code base with :doc:`readability-isolate-declaration <../readability/isolate-declaration>` first. Note that there is the check @@ -58,10 +58,11 @@ Limitations The check does not run on `C` code. -The check will not analyze templated variables or variables that are instantiation dependent. -Different instantiations can result in different ``const`` correctness properties and in general it -is not possible to find all instantiations of a template. The template might be used differently in -an independent translation unit. +The check will not analyze templated variables or variables that are +instantiation dependent. Different instantiations can result in +different ``const`` correctness properties and in general it is not +possible to find all instantiations of a template. The template might +be used differently in an independent translation unit. Options ------- diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc/coroutine-hostile-raii.rst b/clang-tools-extra/docs/clang-tidy/checks/misc/coroutine-hostile-raii.rst index 0b054e4e20bd6..774b42ddba65e 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc/coroutine-hostile-raii.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/misc/coroutine-hostile-raii.rst @@ -7,21 +7,23 @@ Detects when objects of certain hostile RAII types persists across suspension points in a coroutine. Such hostile types include scoped-lockable types and types belonging to a configurable denylist. -Some objects require that they be destroyed on the same thread that created them. -Traditionally this requirement was often phrased as "must be a local variable", -under the assumption that local variables always work this way. However this is -incorrect with C++20 coroutines, since an intervening ``co_await`` may cause the -coroutine to suspend and later be resumed on another thread. - -The lifetime of an object that requires being destroyed on the same thread must -not encompass a ``co_await`` or ``co_yield`` point. If you create/destroy an object, -you must do so without allowing the coroutine to suspend in the meantime. +Some objects require that they be destroyed on the same thread that created +them. Traditionally this requirement was often phrased as "must be a local +variable", under the assumption that local variables always work this way. +However this is incorrect with C++20 coroutines, since an intervening +``co_await`` may cause the coroutine to suspend and later be resumed on +another thread. + +The lifetime of an object that requires being destroyed on the same thread +must not encompass a ``co_await`` or ``co_yield`` point. If you create/destroy +an object, you must do so without allowing the coroutine to suspend in the +meantime. Following types are considered as hostile: - - Scoped-lockable types: A scoped-lockable object persisting across a suspension - point is problematic as the lock held by this object could be unlocked by a - different thread. This would be undefined behaviour. + - Scoped-lockable types: A scoped-lockable object persisting across a + suspension point is problematic as the lock held by this object could + be unlocked by a different thread. This would be undefined behaviour. This includes all types annotated with the ``scoped_lockable`` attribute. - Types belonging to a configurable denylist. diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc/header-include-cycle.rst b/clang-tools-extra/docs/clang-tidy/checks/misc/header-include-cycle.rst index de08f0d0bea07..d0ae0ea84aad4 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc/header-include-cycle.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/misc/header-include-cycle.rst @@ -47,18 +47,18 @@ quality, and a more maintainable codebase overall. Additionally, by ensuring that header files are organized in a way that avoids cyclic dependencies, developers can make their code easier to understand and modify over time. -It's worth noting that only user-defined headers their dependencies are analyzed, -System includes such as standard library headers and third-party library headers -are excluded. System includes are usually well-designed and free of include -cycles, and ignoring them helps to focus on potential issues within the -project's own codebase. This limitation doesn't diminish the ability to detect -``#include`` cycles within the analyzed code. +It's worth noting that only user-defined headers their dependencies are +analyzed, system includes such as standard library headers and third-party +library headers are excluded. System includes are usually well-designed and +free of include cycles, and ignoring them helps to focus on potential issues +within the project's own codebase. This limitation doesn't diminish the +ability to detect ``#include`` cycles within the analyzed code. Developers should carefully review any warnings or feedback provided by this solution. While the analysis aims to identify and prevent include cycles, there may be situations where exceptions or modifications are necessary. It's -important to exercise judgment and consider the specific context of the codebase -when making adjustments. +important to exercise judgment and consider the specific context of the +codebase when making adjustments. Options ------- diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc/misleading-identifier.rst b/clang-tools-extra/docs/clang-tidy/checks/misc/misleading-identifier.rst index 1e2b61ac67345..5941d1ca9b9c0 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc/misleading-identifier.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/misc/misleading-identifier.rst @@ -4,8 +4,8 @@ misc-misleading-identifier ========================== Finds identifiers that contain Unicode characters with right-to-left direction, -which can be confusing as they may change the understanding of a whole statement -line, as described in `Trojan Source `_. +which can be confusing as they may change the understanding of a whole +statement line, as described in `Trojan Source `_. An example of such misleading code follows: diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc/no-recursion.rst b/clang-tools-extra/docs/clang-tidy/checks/misc/no-recursion.rst index 1c04dbfcad532..53753f1d029d0 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc/no-recursion.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/misc/no-recursion.rst @@ -11,7 +11,8 @@ and displays one example of a possible call graph loop (recursion). References: * CERT C++ Coding Standard rule `DCL56-CPP. Avoid cycles during initialization of static objects `_. -* JPL Institutional Coding Standard for the C Programming Language (JPL DOCID D-60411) rule `2.4 Do not use direct or indirect recursion`. +* JPL Institutional Coding Standard for the C Programming Language + (JPL DOCID D-60411) rule `2.4 Do not use direct or indirect recursion`. * OpenCL Specification, Version 1.2 rule `6.9 Restrictions: i. Recursion is not supported. `_. diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc/override-with-different-visibility.rst b/clang-tools-extra/docs/clang-tidy/checks/misc/override-with-different-visibility.rst index 24be51b53c9c4..9958df5000b63 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc/override-with-different-visibility.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/misc/override-with-different-visibility.rst @@ -5,11 +5,12 @@ misc-override-with-different-visibility Finds virtual function overrides with different visibility than the function in the base class. This includes for example if a virtual function declared as -``private`` is overridden and declared as ``public`` in a subclass. The detected -change is the modification of visibility resulting from keywords ``public``, -``protected``, ``private`` at overridden virtual functions. The check applies to -any normal virtual function and optionally to destructors or operators. Use of -the ``using`` keyword is not considered as visibility change by this check. +``private`` is overridden and declared as ``public`` in a subclass. The +detected change is the modification of visibility resulting from keywords +``public``, ``protected``, ``private`` at overridden virtual functions. The +check applies to any normal virtual function and optionally to destructors or +operators. Use of the ``using`` keyword is not considered as visibility +change by this check. .. code-block:: c++ diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc/throw-by-value-catch-by-reference.rst b/clang-tools-extra/docs/clang-tidy/checks/misc/throw-by-value-catch-by-reference.rst index b89fbe8b44665..cfea1c81fe655 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc/throw-by-value-catch-by-reference.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/misc/throw-by-value-catch-by-reference.rst @@ -7,16 +7,16 @@ misc-throw-by-value-catch-by-reference Finds violations of the rule "Throw by value, catch by reference" presented for example in "C++ Coding Standards" by H. Sutter and A. Alexandrescu, as well as -the CERT C++ Coding Standard rule `ERR61-CPP. Catch exceptions by lvalue reference -`_. +the CERT C++ Coding Standard rule `ERR61-CPP. Catch exceptions by lvalue +reference `_. Exceptions: * Throwing string literals will not be flagged despite being a pointer. They are not susceptible to slicing and the usage of string literals is idiomatic. - * Catching character pointers (``char``, ``wchar_t``, unicode character types) - will not be flagged to allow catching string literals. + * Catching character pointers (``char``, ``wchar_t``, unicode character + types) will not be flagged to allow catching string literals. * Moved named values will not be flagged as not throwing an anonymous temporary. In this case we can be sure that the user knows that the object can't be accessed outside catch blocks handling the error. diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc/unused-parameters.rst b/clang-tools-extra/docs/clang-tidy/checks/misc/unused-parameters.rst index 9321f651fd705..3d902452f81eb 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc/unused-parameters.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/misc/unused-parameters.rst @@ -8,9 +8,9 @@ code (e.g. when a different parameter is used instead). The suggested fixes either comment parameter name out or remove the parameter completely, if all callers of the function are in the same translation unit and can be updated. -The check is similar to the ``-Wunused-parameter`` compiler diagnostic and can be -used to prepare a codebase to enabling of that diagnostic. By default the check -is more permissive (see :option:`StrictMode`). +The check is similar to the `-Wunused-parameter` compiler diagnostic and +can be used to prepare a codebase to enabling of that diagnostic. By default +the check is more permissive (see :option:`StrictMode`). .. code-block:: c++ diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc/unused-using-decls.rst b/clang-tools-extra/docs/clang-tidy/checks/misc/unused-using-decls.rst index 29cd5a23589c0..17544656a5fe3 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc/unused-using-decls.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/misc/unused-using-decls.rst @@ -5,9 +5,10 @@ misc-unused-using-decls Finds unused ``using`` declarations. -Unused ``using``` declarations in header files will not be diagnosed since these -using declarations are part of the header's public API. Allowed header file -extensions can be configured via the global option `HeaderFileExtensions`. +Unused ``using`` declarations in header files will not be diagnosed +since these using declarations are part of the header's public API. +Allowed header file extensions can be configured via the global +option `HeaderFileExtensions`. Example: diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc/use-anonymous-namespace.rst b/clang-tools-extra/docs/clang-tidy/checks/misc/use-anonymous-namespace.rst index 09501270fb623..102052dd1581a 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc/use-anonymous-namespace.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/misc/use-anonymous-namespace.rst @@ -8,16 +8,16 @@ that could instead be moved into an anonymous namespace. Anonymous namespaces are the "superior alternative" according to the C++ Standard. ``static`` was proposed for deprecation, but later un-deprecated to -keep C compatibility [1]. ``static`` is an overloaded term with different meanings in -different contexts, so it can create confusion. +keep C compatibility [1]. ``static`` is an overloaded term with different +meanings in different contexts, so it can create confusion. The following uses of ``static`` will *not* be diagnosed: * Functions or variables in header files, since anonymous namespaces in headers - is considered an antipattern. Allowed header file extensions can be configured - via the global option `HeaderFileExtensions`. -* ``const`` or ``constexpr`` variables, since they already have implicit internal - linkage in C++. + is considered an antipattern. Allowed header file extensions can be + configured via the global option `HeaderFileExtensions`. +* ``const`` or ``constexpr`` variables, since they already have implicit + internal linkage in C++. Examples: diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-setjmp-longjmp.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-setjmp-longjmp.rst index ae45619a01945..744a12cc3fc6d 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-setjmp-longjmp.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-setjmp-longjmp.rst @@ -3,7 +3,8 @@ modernize-avoid-setjmp-longjmp ============================== -Flags all call expressions involving ``setjmp()`` and ``longjmp()`` in C++ code. +Flags all call expressions involving ``setjmp()`` and +``longjmp()`` in C++ code. Exception handling with ``throw`` and ``catch`` should be used instead. diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-variadic-functions.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-variadic-functions.rst index 1c93c6b325527..5b1da418cf45d 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-variadic-functions.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/avoid-variadic-functions.rst @@ -15,4 +15,4 @@ References This check corresponds to the CERT C++ Coding Standard rule `DCL50-CPP. Do not define a C-style variadic function -`_. \ No newline at end of file +`_. diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/concat-nested-namespaces.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/concat-nested-namespaces.rst index af2378e805223..6e1f5055b38ec 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/modernize/concat-nested-namespaces.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/concat-nested-namespaces.rst @@ -3,8 +3,10 @@ modernize-concat-nested-namespaces ================================== -Checks for use of nested namespaces such as ``namespace a { namespace b { ... } }`` -and suggests changing to the more concise syntax introduced in C++17: ``namespace a::b { ... }``. +Checks for use of nested namespaces such as +``namespace a { namespace b { ... } }`` +and suggests changing to the more concise syntax introduced +in C++17: ``namespace a::b { ... }``. Inline namespaces are not modified. For example: 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 58d61d1cdbf1f..e11ced7796c5e 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 @@ -107,7 +107,8 @@ Original: for (int i = 0; i < size(v); ++i) cout << v[i]; -After applying the check with minimum confidence level set to `reasonable` (default): +After applying the check with minimum confidence level set to +`reasonable` (default): .. code-block:: c++ @@ -320,6 +321,6 @@ not be used on code with a compatibility requirement of OpenMP prior to version 5. It is **intentional** that this check does not make any attempts to exclude incorrect diagnostics on OpenMP for loops prior to OpenMP 5. -To prevent this check to be applied (and to break) OpenMP for loops but still be -applied to non-OpenMP for loops the usage of ``NOLINT`` (see -:ref:`clang-tidy-nolint`) on the specific for loops is recommended. +To prevent this check to be applied (and to break) OpenMP for loops +but still be applied to non-OpenMP for loops the usage of ``NOLINT`` +(see :ref:`clang-tidy-nolint`) on the specific for loops is recommended. diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/replace-disallow-copy-and-assign-macro.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/replace-disallow-copy-and-assign-macro.rst index 5ef6ae7893e9d..485abca339050 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/modernize/replace-disallow-copy-and-assign-macro.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/replace-disallow-copy-and-assign-macro.rst @@ -38,9 +38,9 @@ Limitations ----------- * Notice that the migration example above leaves the ``private`` access - specification untouched. You might want to run the check :doc:`modernize-use-equals-delete - <../modernize/use-equals-delete>` to get warnings for deleted functions in - private sections. + specification untouched. You might want to run the check + :doc:`modernize-use-equals-delete <../modernize/use-equals-delete>` + to get warnings for deleted functions in private sections. Options ------- diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/replace-random-shuffle.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/replace-random-shuffle.rst index 546de84a782b7..c6dcd722d7ad7 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/modernize/replace-random-shuffle.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/replace-random-shuffle.rst @@ -3,9 +3,12 @@ modernize-replace-random-shuffle ================================ -This check will find occurrences of ``std::random_shuffle`` and replace it with ``std::shuffle``. In C++17 ``std::random_shuffle`` will no longer be available and thus we need to replace it. +This check will find occurrences of ``std::random_shuffle`` and replace it with +``std::shuffle``. In C++17 ``std::random_shuffle`` will no longer be available +and thus we need to replace it. -Below are two examples of what kind of occurrences will be found and two examples of what it will be replaced with. +Below are two examples of what kind of occurrences will be found and two +examples of what it will be replaced with. .. code-block:: c++ @@ -23,10 +26,18 @@ Both of these examples will be replaced with: std::shuffle(vec.begin(), vec.end(), std::mt19937(std::random_device()())); -The second example will also receive a warning that ``randomFunc`` is no longer supported in the same way as before so if the user wants the same functionality, the user will need to change the implementation of the ``randomFunc``. +The second example will also receive a warning that ``randomFunc`` is no longer +supported in the same way as before so if the user wants the same +functionality, the user will need to change the implementation of the +``randomFunc``. -One thing to be aware of here is that ``std::random_device`` is quite expensive to initialize. So if you are using the code in a performance critical place, you probably want to initialize it elsewhere. -Another thing is that the seeding quality of the suggested fix is quite poor: ``std::mt19937`` has an internal state of 624 32-bit integers, but is only seeded with a single integer. So if you require +One thing to be aware of here is that ``std::random_device`` is quite expensive +to initialize. So if you are using the code in a performance critical place, +you probably want to initialize it elsewhere. + +Another thing is that the seeding quality of the suggested fix is quite poor: +``std::mt19937`` has an internal state of 624 32-bit integers, but is only +seeded with a single integer. So if you require higher quality randomness, you should consider seeding better, for example: .. code-block:: c++ diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/type-traits.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/type-traits.rst index c0cffde820e84..fbe2b856c6b85 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/modernize/type-traits.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/type-traits.rst @@ -4,7 +4,8 @@ modernize-type-traits ===================== Converts standard library type traits of the form ``traits<...>::type`` and -``traits<...>::value`` into ``traits_t<...>`` and ``traits_v<...>`` respectively. +``traits<...>::value`` into ``traits_t<...>`` and +``traits_v<...>`` respectively. For example: diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/unary-static-assert.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/unary-static-assert.rst index 31ece10124cd1..9a0de6c981e59 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/modernize/unary-static-assert.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/unary-static-assert.rst @@ -3,8 +3,9 @@ modernize-unary-static-assert ============================= -The check diagnoses any ``static_assert`` declaration with an empty string literal -and provides a fix-it to replace the declaration with a single-argument ``static_assert`` declaration. +The check diagnoses any ``static_assert`` declaration with an +empty string literal and provides a fix-it note to replace the +declaration with a single-argument ``static_assert`` declaration. The check is only applicable for C++17 and later code. diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-auto.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-auto.rst index 67536173aa4c6..3cd37e0eac50a 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-auto.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-auto.rst @@ -163,8 +163,8 @@ The check handles ``static_cast``, ``dynamic_cast``, ``const_cast``, ``reinterpret_cast``, functional casts, C-style casts and function templates that behave as casts, such as ``llvm::dyn_cast``, ``boost::lexical_cast`` and ``gsl::narrow_cast``. Calls to function templates are considered to behave as -casts if the first template argument is explicit and is a type, and the function -returns that type, or a pointer or reference to it. +casts if the first template argument is explicit and is a type, and the +function returns that type, or a pointer or reference to it. Limitations diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-constraints.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-constraints.rst index a8b31b80e580b..232cd01dc22d1 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-constraints.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-constraints.rst @@ -6,8 +6,8 @@ modernize-use-constraints Replace ``std::enable_if`` with C++20 requires clauses. ``std::enable_if`` is a SFINAE mechanism for selecting the desired function or -class template based on type traits or other requirements. ``enable_if`` changes -the meta-arity of the template, and has other +class template based on type traits or other requirements. ``enable_if`` +changes the meta-arity of the template, and has other `adverse side effects `_ in the code. C++20 introduces concepts and constraints as a cleaner language diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-designated-initializers.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-designated-initializers.rst index 62ea906d7a029..1b8c9c39c0e03 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-designated-initializers.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-designated-initializers.rst @@ -3,8 +3,8 @@ modernize-use-designated-initializers ===================================== -Finds initializer lists for aggregate types which could be written as designated -initializers instead. +Finds initializer lists for aggregate types which could be written as +designated initializers instead. With plain initializer lists, it is very easy to introduce bugs when adding new fields in the middle of a struct or class type. The same confusion might arise @@ -38,9 +38,9 @@ declaration of ``S``. Even when compiling in a language version older than C++20, depending on your compiler, designated initializers are potentially supported. Therefore, the check is by default restricted to C99/C++20 and above. Check out the options -``-Wc99-designator`` to get support for mixed designators in initializer list in -C and ``-Wc++20-designator`` for support of designated initializers in older C++ -language modes. +`-Wc99-designator` to get support for mixed designators in initializer list +in C and `-Wc++20-designator` for support of designated initializers in older +C++ language modes. Options ------- 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 e020ece296475..f1031f69a9467 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 @@ -17,19 +17,22 @@ The :option:`ContainersWithPushBack`, :option:`ContainersWithPush`, and types that support the ``push_back``, ``push``, and ``push_front`` operations respectively. The default values for these options are as follows: -* :option:`ContainersWithPushBack`: ``std::vector``, ``std::deque``, and ``std::list``. -* :option:`ContainersWithPush`: ``std::stack``, ``std::queue``, and ``std::priority_queue``. -* :option:`ContainersWithPushFront`: ``std::forward_list``, ``std::list``, and ``std::deque``. +* :option:`ContainersWithPushBack`: ``std::vector``, ``std::deque``, + and ``std::list``. +* :option:`ContainersWithPush`: ``std::stack``, ``std::queue``, + and ``std::priority_queue``. +* :option:`ContainersWithPushFront`: ``std::forward_list``, + ``std::list``, and ``std::deque``. This check also reports when an ``emplace``-like method is improperly used, for example using ``emplace_back`` while also calling a constructor. This -creates a temporary that requires at best a move and at worst a copy. Almost all -``emplace``-like functions in the STL are covered by this, with ``try_emplace`` -on ``std::map`` and ``std::unordered_map`` being the exception as it behaves -slightly differently than all the others. More containers can be added with the -:option:`EmplacyFunctions` option, so long as the container defines a -``value_type`` type, and the ``emplace``-like functions construct a -``value_type`` object. +creates a temporary that requires at best a move and at worst a copy. Almost +all ``emplace``-like functions in the STL are covered by this, with +``try_emplace`` on ``std::map`` and ``std::unordered_map`` being the +exception as it behaves slightly differently than all the others. More +containers can be added with the :option:`EmplacyFunctions` option, so long +as the container defines a ``value_type`` type, and the ``emplace``-like +functions construct a ``value_type`` object. Before: diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-equals-delete.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-equals-delete.rst index d354fcc6060ce..f632c81b5fbc4 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-equals-delete.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-equals-delete.rst @@ -13,9 +13,9 @@ definition. This approach would result in either a compiler error (when attempting to call a private function) or a linker error (due to an undefined reference). -However, subsequent to the advent of C++11, a more conventional approach emerged -for achieving this purpose. It involves flagging functions as ``= delete`` and -keeping them in the ``public`` section of the class. +However, subsequent to the advent of C++11, a more conventional approach +emerged for achieving this purpose. It involves flagging functions as +``= delete`` and keeping them in the ``public`` section of the class. To prevent false positives, this check is only active within a translation unit where all other member functions have been implemented. The check will diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-format.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-format.rst index 21bb254217910..e87825f6114d8 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-format.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-format.rst @@ -22,7 +22,7 @@ into: return std::format("The {} is {:3}", description, value); The check uses the same format-string-conversion algorithm as -`modernize-use-std-print <../modernize/use-std-print.html>`_ and its +:doc:`modernize-use-std-print <../modernize/use-std-print>` and its shortcomings and behaviour in combination with macros are described in the documentation for that check. diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst index 3005708c6f8a8..4641975cf2c76 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst @@ -7,9 +7,11 @@ Converts calls to ``printf``, ``fprintf``, ``absl::PrintF`` and ``absl::FPrintf`` to equivalent calls to C++23's ``std::print`` or ``std::println`` as appropriate, modifying the format string appropriately. The replaced and replacement functions can be customised by configuration -options. Each argument that is the result of a call to ``std::string::c_str()`` and -``std::string::data()`` will have that now-unnecessary call removed in a -similar manner to the `readability-redundant-string-cstr` check. +options. Each argument that is the result of a call to +``std::string::c_str()`` and ``std::string::data()`` will have that +now-unnecessary call removed in a similar manner to the +:doc:`readability-redundant-string-cstr +<../readability/redundant-string-cstr>` check. In other words, it turns lines like: diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-trailing-return-type.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-trailing-return-type.rst index 63b8885014e60..f74158bd63090 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-trailing-return-type.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-trailing-return-type.rst @@ -37,9 +37,12 @@ The following categories of return types cannot be rewritten currently: * member function pointers * member pointers -Unqualified names in the return type might erroneously refer to different entities after the rewrite. -Preventing such errors requires a full lookup of all unqualified names present in the return type in the scope of the trailing return type location. -This location includes e.g. function parameter names and members of the enclosing class (including all inherited classes). +Unqualified names in the return type might erroneously refer to different +entities after the rewrite. +Preventing such errors requires a full lookup of all unqualified names +present in the return type in the scope of the trailing return type location. +This location includes e.g. function parameter names and members of the +enclosing class (including all inherited classes). Such a lookup is currently not implemented. Given the following piece of code @@ -66,7 +69,8 @@ a careless rewrite would produce the following output: }; auto CC::m() -> S { return {0}; } // error -This code fails to compile because the S in the context of f refers to the equally named function parameter. +This code fails to compile because the S in the context of f refers to the +equally named function parameter. Similarly, the S in the context of m refers to the equally named class member. The check can currently only detect and avoid a clash with a function parameter name. diff --git a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-using.rst b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-using.rst index 32272a07994c2..9eedf20cb9723 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/modernize/use-using.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/modernize/use-using.rst @@ -48,5 +48,5 @@ Options .. option:: IgnoreExternC - If set to `true`, the check will not give warning inside `extern "C"`scope. - Default is `false` \ No newline at end of file + If set to `true`, the check will not give warning inside ``extern "C"`` + scope. Default is `false`