[clang-tidy] Fix reST syntax

Authored by Eisuke Kawashima [https://github.com/llvm/llvm-project/pull/245]
This commit is contained in:
serge-sans-paille 2020-09-08 14:38:16 +02:00
parent 576bd52f77
commit 875b8537ee
21 changed files with 102 additions and 98 deletions

View File

@ -29,6 +29,7 @@ Options
account.
.. option:: IgnoreSingleArgument
When true, the check will ignore the single argument.
.. option:: CommentBoolLiterals

View File

@ -5,6 +5,7 @@ bugprone-exception-escape
Finds functions which may throw an exception directly or indirectly, but they
should not. The functions which should not throw exceptions are the following:
* Destructors
* Move constructors
* Move assignment operators

View File

@ -37,7 +37,7 @@ The check warns for constructors C1 and C2, because those can hide copy and move
constructors. We suppress warnings if the copy and the move constructors are both
disabled (deleted or private), because there is nothing the perfect forwarding
constructor could hide in this case. We also suppress warnings for constructors
like C3 that are guarded with an enable_if, assuming the programmer was aware of
like C3 that are guarded with an ``enable_if``, assuming the programmer was aware of
the possible hiding.
Background
@ -45,5 +45,5 @@ Background
For deciding whether a constructor is guarded with enable_if, we consider the
default values of the type parameters and the types of the constructor
parameters. If any part of these types is std::enable_if or std::enable_if_t, we
assume the constructor is guarded.
parameters. If any part of these types is ``std::enable_if`` or ``std::enable_if_t``,
we assume the constructor is guarded.

View File

@ -10,7 +10,7 @@ is almost never what was intended.
Example:
.. code-block:: c++
void FancyFunction() {
[] { printf("Called from %s\n", __func__); }();
[] { printf("Now called from %s\n", __FUNCTION__); }();

View File

@ -5,7 +5,7 @@ bugprone-not-null-terminated-result
Finds function calls where it is possible to cause a not null-terminated result.
Usually the proper length of a string is ``strlen(src) + 1`` or equal length of
this expression, because the null terminator needs an extra space. Without the
this expression, because the null terminator needs an extra space. Without the
null terminator it can result in undefined behaviour when the string is read.
The following and their respective ``wchar_t`` based functions are checked:
@ -17,27 +17,27 @@ The following is a real-world example where the programmer forgot to increase
the passed third argument, which is ``size_t length``. That is why the length
of the allocated memory is not enough to hold the null terminator.
.. code-block:: c
.. code-block:: c
static char *stringCpy(const std::string &str) {
char *result = reinterpret_cast<char *>(malloc(str.size()));
memcpy(result, str.data(), str.size());
return result;
}
static char *stringCpy(const std::string &str) {
char *result = reinterpret_cast<char *>(malloc(str.size()));
memcpy(result, str.data(), str.size());
return result;
}
In addition to issuing warnings, fix-it rewrites all the necessary code. It also
tries to adjust the capacity of the destination array:
.. code-block:: c
.. code-block:: c
static char *stringCpy(const std::string &str) {
char *result = reinterpret_cast<char *>(malloc(str.size() + 1));
strcpy(result, str.data());
return result;
}
static char *stringCpy(const std::string &str) {
char *result = reinterpret_cast<char *>(malloc(str.size() + 1));
strcpy(result, str.data());
return result;
}
Note: It cannot guarantee to rewrite every of the path-sensitive memory
allocations.
allocations.
.. _MemcpyTransformation:

View File

@ -19,7 +19,7 @@ Options
-------
.. option:: HeaderFileExtensions
Default value: `";h;hh;hpp;hxx"`
Default value: ``";h;hh;hpp;hxx"``
A semicolon-separated list of filename extensions of header files (the
filename extensions should not contain a "." prefix). For extension-less
header files, use an empty string or leave an empty string between ";"
@ -27,6 +27,6 @@ Options
.. option:: ImplementationFileExtensions
Default value: `"c;cc;cpp;cxx"`
Default value: ``"c;cc;cpp;cxx"``
Likewise, a semicolon-separated list of filename extensions of
implementation files.

View File

@ -46,14 +46,14 @@ Options
.. option:: SizeThreshold
An unsigned integer specifying the minimum size of a string literal to be
considered by the check. Default is `5U`.
considered by the check. Default is ``5U``.
.. option:: RatioThreshold
A string specifying the maximum threshold ratio [0, 1.0] of suspicious string
literals to be considered. Default is `".2"`.
literals to be considered. Default is ``".2"``.
.. option:: MaxConcatenatedTokens
An unsigned integer specifying the maximum number of concatenated tokens.
Default is `5U`.
Default is ``5U``.

View File

@ -3,15 +3,15 @@
bugprone-terminating-continue
=============================
Detects `do while` loops with a condition always evaluating to false that
have a `continue` statement, as this `continue` terminates the loop
Detects ``do while`` loops with a condition always evaluating to false that
have a ``continue`` statement, as this ``continue`` terminates the loop
effectively.
.. code-block:: c++
void f() {
do {
// some code
// some code
continue; // terminating continue
// some other code
} while(false);

View File

@ -1,10 +1,10 @@
.. title:: clang-tidy - cert-con36-c
.. meta::
:http-equiv=refresh: 5;URL=bugprone-spuriously-wake-up-functions.html
cert-con36-c
============
The cert-con36-c check is an alias, please see
`bugprone-spuriously-wake-up-functions <bugprone-spuriously-wake-up-functions.html>`_
`bugprone-spuriously-wake-up-functions <bugprone-spuriously-wake-up-functions.html>`_
for more information.

View File

@ -1,10 +1,10 @@
.. title:: clang-tidy - cert-con54-cpp
.. meta::
:http-equiv=refresh: 5;URL=bugprone-spuriously-wake-up-functions.html
cert-con54-cpp
==============
The cert-con54-cpp check is an alias, please see
`bugprone-spuriously-wake-up-functions <bugprone-spuriously-wake-up-functions.html>`_
`bugprone-spuriously-wake-up-functions <bugprone-spuriously-wake-up-functions.html>`_
for more information.

View File

@ -3,8 +3,8 @@
cppcoreguidelines-avoid-non-const-global-variables
==================================================
Finds non-const global variables as described in `I.2 of C++ Core Guidelines <https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Ri-global>` .
As `R.6 of C++ Core Guidelines <https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rr-global>` is a duplicate of rule I.2 it also covers that rule.
Finds non-const global variables as described in `I.2 of C++ Core Guidelines <https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Ri-global>`_ .
As `R.6 of C++ Core Guidelines <https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rr-global>`_ is a duplicate of rule I.2 it also covers that rule.
.. code-block:: c++

View File

@ -9,8 +9,8 @@ pattern of variable names in Google's Objective-C Style Guide.
The corresponding style guide rule:
https://google.github.io/styleguide/objcguide.html#variable-names
All the global variables should follow the pattern of `g[A-Z].*` (variables) or
`k[A-Z].*` (constants). The check will suggest a variable name that follows the
All the global variables should follow the pattern of ``g[A-Z].*`` (variables) or
``k[A-Z].*`` (constants). The check will suggest a variable name that follows the
pattern if it can be inferred from the original name.
For code:

View File

@ -9,6 +9,6 @@ https://google.github.io/styleguide/cppguide.html#Casting
Corresponding cpplint.py check name: `readability/casting`.
This check is similar to `-Wold-style-cast`, but it suggests automated fixes
This check is similar to ``-Wold-style-cast``, but it suggests automated fixes
in some cases. The reported locations should not be different from the
ones generated by `-Wold-style-cast`.
ones generated by ``-Wold-style-cast``.

View File

@ -8,7 +8,7 @@ This check diagnoses when a ``const`` qualifier is applied to a ``typedef``/
are often misleading to developers because the ``const`` applies to the pointer
rather than the pointee.
For instance, in the following code, the resulting type is ``int *`` ``const``
For instance, in the following code, the resulting type is ``int * const``
rather than ``const int *``:
.. code-block:: c++

View File

@ -9,10 +9,12 @@ diagnoses each function in the cycle,
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 <https://wiki.sei.cmu.edu/confluence/display/cplusplus/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`.
* OpenCL Specification, Version 1.2 rule `6.9 Restrictions: i. Recursion is not supported. <https://www.khronos.org/registry/OpenCL/specs/opencl-1.2.pdf>`_.
Limitations:
* The check does not handle calls done through function pointers
* The check does not handle C++ destructors

View File

@ -8,7 +8,7 @@ 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
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`).

View File

@ -37,7 +37,7 @@ Known 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
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.

View File

@ -15,25 +15,25 @@ Example
.. code-block:: c++
void foo() throw();
void bar() throw(int) {}
void bar() throw(int) {}
transforms to:
.. code-block:: c++
void foo() noexcept;
void bar() noexcept(false) {}
void bar() noexcept(false) {}
Options
-------
.. option:: ReplacementString
Users can use :option:`ReplacementString` to specify a macro to use
instead of ``noexcept``. This is useful when maintaining source code
that uses custom exception specification marking other than
``noexcept``. Fix-it hints will only be generated for non-throwing
specifications.
Users can use :option:`ReplacementString` to specify a macro to use
instead of ``noexcept``. This is useful when maintaining source code
that uses custom exception specification marking other than
``noexcept``. Fix-it hints will only be generated for non-throwing
specifications.
Example
^^^^^^^

View File

@ -12,53 +12,53 @@ they will be replaced with.
.. code-block:: c++
#define MACRO1 std::uncaught_exception
#define MACRO2 std::uncaught_exception
#define MACRO1 std::uncaught_exception
#define MACRO2 std::uncaught_exception
int uncaught_exception() {
return 0;
}
int uncaught_exception() {
return 0;
}
int main() {
int res;
int main() {
int res;
res = uncaught_exception();
// No warning, since it is not the deprecated function from namespace std
res = MACRO2();
// Warning, but will not be replaced
res = std::uncaught_exception();
// Warning and replaced
using std::uncaught_exception;
// Warning and replaced
res = uncaught_exception();
// Warning and replaced
}
res = uncaught_exception();
// No warning, since it is not the deprecated function from namespace std
res = MACRO2();
// Warning, but will not be replaced
res = std::uncaught_exception();
// Warning and replaced
using std::uncaught_exception;
// Warning and replaced
res = uncaught_exception();
// Warning and replaced
}
After applying the fixes the code will look like the following:
.. code-block:: c++
#define MACRO1 std::uncaught_exception
#define MACRO2 std::uncaught_exception
#define MACRO1 std::uncaught_exception
#define MACRO2 std::uncaught_exception
int uncaught_exception() {
return 0;
}
int uncaught_exception() {
return 0;
}
int main() {
int res;
res = uncaught_exception();
res = MACRO2();
res = std::uncaught_exceptions();
using std::uncaught_exceptions;
res = uncaught_exceptions();
}
int main() {
int res;
res = uncaught_exception();
res = MACRO2();
res = std::uncaught_exceptions();
using std::uncaught_exceptions;
res = uncaught_exceptions();
}

View File

@ -11,7 +11,7 @@ return types.
Examples:
.. code-block:: c++
const int foo();
const Clazz foo();
Clazz *const foo();

View File

@ -3,12 +3,12 @@
zircon-temporary-objects
========================
Warns on construction of specific temporary objects in the Zircon kernel.
If the object should be flagged, If the object should be flagged, the fully
Warns on construction of specific temporary objects in the Zircon kernel.
If the object should be flagged, If the object should be flagged, the fully
qualified type name must be explicitly passed to the check.
For example, given the list of classes "Foo" and "NS::Bar", all of the
following will trigger the warning:
For example, given the list of classes "Foo" and "NS::Bar", all of the
following will trigger the warning:
.. code-block:: c++
@ -26,14 +26,14 @@ With the same list, the following will not trigger the warning:
.. code-block:: c++
Foo F; // Non-temporary construction okay
Foo F(param); // Non-temporary construction okay
Foo *F = new Foo(); // New construction okay
Foo F; // Non-temporary construction okay
Foo F(param); // Non-temporary construction okay
Foo *F = new Foo(); // New construction okay
Bar(); // Not NS::Bar, so okay
NS::Bar B; // Non-temporary construction okay
Bar(); // Not NS::Bar, so okay
NS::Bar B; // Non-temporary construction okay
Note that objects must be explicitly specified in order to be flagged,
Note that objects must be explicitly specified in order to be flagged,
and so objects that inherit a specified object will not be flagged.
This check matches temporary objects without regard for inheritance and so a
@ -49,5 +49,5 @@ Options
.. option:: Names
A semi-colon-separated list of fully-qualified names of C++ classes that
A semi-colon-separated list of fully-qualified names of C++ classes that
should not be constructed as temporaries. Default is empty.