Index: docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst =================================================================== --- docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst +++ docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst @@ -6,9 +6,9 @@ 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. +arrays, see the `clang-diagnostic-array-bounds` check. -The check can generate fixes after the option `GslHeader` has been set +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"`. This rule is part of the "Bounds safety" profile of the C++ Core Guidelines, see Index: docs/clang-tidy/checks/google-global-names-in-headers.rst =================================================================== --- docs/clang-tidy/checks/google-global-names-in-headers.rst +++ docs/clang-tidy/checks/google-global-names-in-headers.rst @@ -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. +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. +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. + The relevant style guide section is https://google.github.io/styleguide/cppguide.html#Namespaces. Index: docs/clang-tidy/checks/misc-argument-comment.rst =================================================================== --- docs/clang-tidy/checks/misc-argument-comment.rst +++ docs/clang-tidy/checks/misc-argument-comment.rst @@ -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. Index: docs/clang-tidy/checks/misc-misplaced-widening-cast.rst =================================================================== --- docs/clang-tidy/checks/misc-misplaced-widening-cast.rst +++ docs/clang-tidy/checks/misc-misplaced-widening-cast.rst @@ -8,33 +8,39 @@ 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; + return (long) x * 1000; } 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 (default) +the check also detects these cases, for instance: +.. code-block:: c++ + long f(int x) { return x * 1000; } @@ -43,8 +49,10 @@ -------------- 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); + return (double) (x * 10.0f); } Index: docs/clang-tidy/checks/misc-suspicious-missing-comma.rst =================================================================== --- docs/clang-tidy/checks/misc-suspicious-missing-comma.rst +++ docs/clang-tidy/checks/misc-suspicious-missing-comma.rst @@ -9,16 +9,15 @@ 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 @@ "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", }; - Index: docs/clang-tidy/checks/modernize-use-auto.rst =================================================================== --- docs/clang-tidy/checks/modernize-use-auto.rst +++ docs/clang-tidy/checks/modernize-use-auto.rst @@ -145,17 +145,21 @@ 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++ TypeName *my_first_pointer = new TypeName, *my_second_pointer = new TypeName; Index: docs/clang-tidy/checks/readability-braces-around-statements.rst =================================================================== --- docs/clang-tidy/checks/readability-braces-around-statements.rst +++ docs/clang-tidy/checks/readability-braces-around-statements.rst @@ -11,14 +11,14 @@ Before: -.. code:: c++ +.. code-block:: c++ if (condition) statement; After: -.. code:: c++ +.. code-block:: c++ if (condition) { statement; Index: docs/clang-tidy/checks/readability-simplify-boolean-expr.rst =================================================================== --- docs/clang-tidy/checks/readability-simplify-boolean-expr.rst +++ docs/clang-tidy/checks/readability-simplify-boolean-expr.rst @@ -3,7 +3,6 @@ readability-simplify-boolean-expr ================================= - Looks for boolean expressions involving boolean constants and simplifies them to use the appropriate boolean expression directly. @@ -73,9 +72,8 @@ ``struct X``, the conditional return ``if (x) return true; return false;`` becomes ``return static_cast(x);`` -When a conditional boolean return or assignment appears at the end of a -chain of ``if``, ``else if`` statements, the conditional statement is left -unchanged unless the option ``ChainedConditionalReturn`` or -``ChainedConditionalAssignment``, respectively, is specified as non-zero. +When a conditional boolean return or assignment appears at the end of a chain of +``if``, ``else if`` statements, the conditional statement is left unchanged +unless the :option:`ChainedConditionalReturn` or +:option:`ChainedConditionalAssignment`, respectively, is specified as non-zero. The default value for both options is zero. -