[clang-tools-extra] 8fdbc87 - [clang-tidy] Improve documentation for modernize-use-std-print check
Piotr Zegar via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 1 02:26:54 PDT 2023
Author: Mike Crowe
Date: 2023-07-01T08:40:21Z
New Revision: 8fdbc8712c5b65617331b3de43bedd302e9cdbc1
URL: https://github.com/llvm/llvm-project/commit/8fdbc8712c5b65617331b3de43bedd302e9cdbc1
DIFF: https://github.com/llvm/llvm-project/commit/8fdbc8712c5b65617331b3de43bedd302e9cdbc1.diff
LOG: [clang-tidy] Improve documentation for modernize-use-std-print check
Remove incorrect use of double colons so that the code blocks are
rendered correctly to HTML.
Wrap the name of another check in single backticks. Wrap the name of a
macro in double backticks.
Explain that with the default settings the check is only enabled with
C++23 or later standards.
Correct std::string_data() to std::string::data().
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D154151
Added:
Modified:
clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
Removed:
################################################################################
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 8034238bea90ef..ec17b6fbd48f20 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
@@ -9,21 +9,25 @@ Converts calls to ``printf``, ``fprintf``, ``absl::PrintF`` and
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.
+similar manner to the `readability-redundant-string-cstr` check.
-In other words, it turns lines like::
+In other words, it turns lines like:
.. code-block:: c++
fprintf(stderr, "The %s is %3d\n", description.c_str(), value);
-into::
+into:
.. code-block:: c++
std::println(stderr, "The {} is {:3}", description, value);
-It doesn't do a bad job, but it's not perfect. In particular:
+If the `ReplacementPrintFunction` or `ReplacementPrintlnFunction` options
+are left, or assigned to their default values then this check is only
+enabled with `-std=c++23` or later.
+
+The check doesn't do a bad job, but it's not perfect. In particular:
- It assumes that the format string is correct for the arguments. If you
get any warnings when compiling with `-Wformat` then misbehaviour is
@@ -35,7 +39,7 @@ It doesn't do a bad job, but it's not perfect. In particular:
handled. Although it's possible for the check to automatically put the
escapes back, they may not be exactly as they were written (e.g.
``"\x0a"`` will become ``"\n"`` and ``"ab" "cd"`` will become
- ``"abcd"``.) This is helpful since it means that the PRIx macros from
+ ``"abcd"``.) This is helpful since it means that the ``PRIx`` macros from
``<inttypes.h>`` are removed correctly.
- It supports field widths, precision, positional arguments, leading zeros,
@@ -78,7 +82,7 @@ If the call is deemed suitable for conversion then:
signedness will be wrapped in an approprate ``static_cast`` if `StrictMode`
is enabled.
- any arguments that end in a call to ``std::string::c_str()`` or
- ``std::string_data()`` will have that call removed.
+ ``std::string::data()`` will have that call removed.
Options
-------
@@ -99,7 +103,7 @@ Options
unsigned int u = 0xffffffff;
printf("%d %u\n", i, u);
- would be converted to::
+ would be converted to:
.. code-block:: c++
More information about the cfe-commits
mailing list