Skip to content

[clang-tidy] Fix reST syntax #245

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Options
account.

.. option:: IgnoreSingleArgument

When true, the check will ignore the single argument.

.. option:: CommentBoolLiterals
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ 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
----------

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.
Original file line number Diff line number Diff line change
Expand Up @@ -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__); }();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ Known limitations

The ``else`` branch is not checked currently for negated condition variable:

.. code-block:: c

bool onFire = isBurning();
if (onFire) {
scream();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ 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 ";"
if there are other filename extensions.

.. 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.
Original file line number Diff line number Diff line change
Expand Up @@ -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``.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
4 changes: 2 additions & 2 deletions clang-tools-extra/docs/clang-tidy/checks/cert-con36-c.rst
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 2 additions & 2 deletions clang-tools-extra/docs/clang-tidy/checks/cert-con54-cpp.rst
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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++

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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``.
Original file line number Diff line number Diff line change
Expand Up @@ -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++
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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`).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,53 @@ they will be replaced with.

.. code-block:: c++

#define MACRO1 std::uncaught_exception
#define MACRO2 std::uncaught_exception

int uncaught_exception() {
return 0;
}

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
}
#define MACRO1 std::uncaught_exception
#define MACRO2 std::uncaught_exception

int uncaught_exception() {
return 0;
}

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
}

After applying the fixes the code will look like the following:

.. code-block:: c++

#define MACRO1 std::uncaught_exception
#define MACRO2 std::uncaught_exception

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();
}
#define MACRO1 std::uncaught_exception
#define MACRO2 std::uncaught_exception

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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ return types.
Examples:

.. code-block:: c++

const int foo();
const Clazz foo();
Clazz *const foo();
Expand Down
Loading