[PATCH] D154151: [clang-tidy] Improve documentation for modernize-use-std-print check

Mike Crowe via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 29 13:56:51 PDT 2023


mikecrowe created this revision.
mikecrowe added a reviewer: PiotrZSL.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
mikecrowe requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

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().


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154151

Files:
  clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst


Index: clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
===================================================================
--- clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
+++ clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
@@ -9,21 +9,25 @@
 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 @@
   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 @@
   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 @@
     unsigned int u = 0xffffffff;
     printf("%d %u\n", i, u);
 
-  would be converted to::
+  would be converted to:
 
   .. code-block:: c++
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154151.535988.patch
Type: text/x-patch
Size: 2388 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230629/cc607b8d/attachment.bin>


More information about the cfe-commits mailing list