[PATCH] D145885: [clang-tidy] Support readability-redundant-string-cstr.StringParameterFunctions option

Piotr Zegar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 12 14:06:34 PDT 2023


PiotrZSL added inline comments.


================
Comment at: clang-tools-extra/docs/ReleaseNotes.rst:146-148
+  arguments to ``std::print`` and ``std::format``. The same check can be
+  used for functions that behave similarly by using the
+  ``StringParameterFunction`` option.
----------------
``std::print``, ``std::format`` or other functions listed in ``StringParameterFunction`` check option.


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/readability/redundant-string-cstr.rst:14-30
+   A semicolon-separated list of function names for which any arguments
+   which are the result of calling ``std::string::c_str()`` or
+   ``std::string::data()`` should be changed to pass the object directly.
+   This is particularly useful for functions that behave like
+   ``std::format`` and ``std::print`` (though arguments to both of those
+   are already detected automatically in C++20 and C++2b mode
+   respectively.) The names may be free functions, member functions, or
----------------
too much noise in this, configuration example is not needed.
reference to C++20 or std::format/std::print also...

Strongly consider something like:
"A semicolon-separated list of (fully qualified) function/method/operator names, with the requirement that
any parameter currently accepting a 'const char*' input should also be able to accept 'std::string' inputs, 
or proper overload candidates that can do so should exist. This can be used to configure functions such as fmt::format, spdlog::logger::info, or wrappers around these and similar functions. Default value is empty string."


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145885/new/

https://reviews.llvm.org/D145885



More information about the cfe-commits mailing list