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

Mike Crowe via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 12 13:44:43 PDT 2023


mikecrowe created this revision.
mikecrowe added reviewers: PiotrZSL, carlosgalvezp.
Herald added a subscriber: 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.

Many libraries and code bases have functions that work like std::format
and std::print and it would be useful for the
readability-redundant-string-cstr check to work with these functions to
remove unnecessary calls to c_str() among their arguments.

The StringParameterFunctions option contains 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.

For example, when using the {fmt}[1] library, this option can be used to
change arguments to fmt::format and fmt::print.

Depends on D143342 <https://reviews.llvm.org/D143342>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145885

Files:
  clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
  clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/readability/redundant-string-cstr.rst
  clang-tools-extra/test/clang-tidy/checkers/readability/redundant-string-cstr-function.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145885.504468.patch
Type: text/x-patch
Size: 11307 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230312/327263e6/attachment-0001.bin>


More information about the cfe-commits mailing list