Fix style in some Clang-tidy checks documentation.

Differential revision: https://reviews.llvm.org/D23728

llvm-svn: 279494
This commit is contained in:
Eugene Zelenko 2016-08-23 00:19:43 +00:00
parent 7f414b90ab
commit f0ae81da0b
7 changed files with 70 additions and 42 deletions

View File

@ -6,10 +6,15 @@ cppcoreguidelines-pro-bounds-constant-array-index
This check flags all array subscript expressions on static arrays and
``std::arrays`` that either do not have a constant integer expression index or
are out of bounds (for ``std::array``). For out-of-bounds checking of static
arrays, see the clang-diagnostic-array-bounds check.
The check can generate fixes after the option `GslHeader` has been set
to the name of the include file that contains ``gsl::at()``, e.g. `"gsl/gsl.h"`.
arrays, see the `-Warray-bounds` Clang diagnostic.
This rule is part of the "Bounds safety" profile of the C++ Core Guidelines, see
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Pro-bounds-arrayindex.
Options
-------
.. option:: GslHeader
The check can generate fixes after this option has been set to the name of
the include file that contains ``gsl::at()``, e.g. `"gsl/gsl.h"`.

View File

@ -3,15 +3,18 @@
google-global-names-in-headers
==============================
Flag global namespace pollution in header files.
Right now it only triggers on ``using`` declarations and directives.
The check supports these options:
- `HeaderFileExtensions`: a comma-separated list of filename extensions
of header files (the filename extensions should not contain "." prefix).
"h" by default.
For extension-less header files, using an empty string or leaving an
empty string between "," if there are other filename extensions.
Flag global namespace pollution in header files. Right now it only triggers on
``using`` declarations and directives.
The relevant style guide section is
https://google.github.io/styleguide/cppguide.html#Namespaces.
Options
-------
.. option:: HeaderFileExtensions
A comma-separated list of filename extensions of header files (the filename
extensions should not contain "." prefix). "h" by default. For extension-less
header files, using an empty string or leaving an empty string between ","
if there are other filename extensions.

View File

@ -3,22 +3,26 @@
misc-argument-comment
=====================
Checks that argument comments match parameter names.
The check understands argument comments in the form ``/*parameter_name=*/``
that are placed right before the argument.
.. code:: c++
.. code-block:: c++
void f(bool foo);
...
f(/*bar=*/true);
// warning: argument name 'bar' in comment does not match parameter name 'foo'
The check tries to detect typos and suggest automated fixes for them.
Supported options:
- `StrictMode` (local or global): when non-zero, the check will ignore leading
and trailing underscores and case when comparing parameter names.
Options
-------
.. option:: StrictMode
When non-zero, the check will ignore leading and trailing underscores and
case when comparing parameter names.

View File

@ -8,21 +8,25 @@ type. If the intention of the cast is to avoid loss of precision then the cast
is misplaced, and there can be loss of precision. Otherwise the cast is
ineffective.
Example code::
Example code:
.. code-block:: c++
long f(int x) {
return (long)(x*1000);
return (long)(x * 1000);
}
The result x*1000 is first calculated using int precision. If the result
exceeds int precision there is loss of precision. Then the result is casted to
long.
The result ``x * 1000`` is first calculated using ``int`` precision. If the
result exceeds ``int`` precision there is loss of precision. Then the result is
casted to ``long``.
If there is no loss of precision then the cast can be removed or you can
explicitly cast to int instead.
explicitly cast to ``int`` instead.
If you want to avoid loss of precision then put the cast in a proper location,
for instance::
for instance:
.. code-block:: c++
long f(int x) {
return (long)x * 1000;
@ -32,8 +36,10 @@ Implicit casts
--------------
Forgetting to place the cast at all is at least as dangerous and at least as
common as misplacing it. If option ``CheckImplicitCasts`` is enabled (default)
the checker also detects these cases, for instance::
common as misplacing it. If :option:`CheckImplicitCasts` is enabled the check
also detects these cases, for instance:
.. code-block:: c++
long f(int x) {
return x * 1000;
@ -43,8 +49,17 @@ Floating point
--------------
Currently warnings are only written for integer conversion. No warning is
written for this code::
written for this code:
.. code-block:: c++
double f(float x) {
return (double)(x * 10.0f);
}
Options
-------
.. option:: CheckImplicitCasts
If non-zero, enables detection of implicit casts. Default is non-zero.

View File

@ -9,16 +9,15 @@ literal on multiple lines.
For instance, the following declarations are equivalent:
.. code:: c++
.. code-block:: c++
const char* A[] = "This is a test";
const char* B[] = "This" " is a " "test";
A common mistake done by programmers is to forget a comma between two string
literals in an array initializer list.
.. code:: c++
.. code-block:: c++
const char* Test[] = {
"line 1",
@ -28,17 +27,15 @@ literals in an array initializer list.
"line 5"
};
The array contains the string "line 2line3" at offset 1 (i.e. Test[1]). Clang
won't generate warnings at compile time.
This checker may warn incorrectly on cases like:
This check may warn incorrectly on cases like:
.. code:: c++
.. code-block:: c++
const char* SupportedFormat[] = {
"Error %s",
"Code " PRIu64, // May warn here.
"Warning %s",
};

View File

@ -145,16 +145,20 @@ the following conditions are satisfied:
Known Limitations
-----------------
* If the initializer is an explicit conversion constructor, the check will not
replace the type specifier even though it would be safe to do so.
* User-defined iterators are not handled at this time.
RemoveStars option
------------------
If the option is set to non-zero (default is `0`), the check will remove stars
from the non-typedef pointer types when replacing type names with ``auto``.
Otherwise, the check will leave stars. For example:
Options
-------
.. option:: RemoveStars
If the option is set to non-zero (default is `0`), the check will remove
stars from the non-typedef pointer types when replacing type names with
``auto``. Otherwise, the check will leave stars. For example:
.. code-block:: c++

View File

@ -11,14 +11,14 @@ Checks that bodies of ``if`` statements and loops (``for``, ``do while``, and
Before:
.. code:: c++
.. code-block:: c++
if (condition)
statement;
After:
.. code:: c++
.. code-block:: c++
if (condition) {
statement;