[clang-tidy] Support std::format and std::print in readability-redundant-string-cstr
authorMike Crowe <mac@mcrowe.com>
Sun, 12 Mar 2023 21:42:52 +0000 (21:42 +0000)
committerPiotr Zegar <piotr.zegar@nokia.com>
Sun, 12 Mar 2023 21:42:53 +0000 (21:42 +0000)
commit57b78faa9eb08017d95bb4e43242648953b08c13
tree01016590e1a13deb0c7efe7d4c476a29c8b77aa3
parent4483e77b3198acc9b7a96db1194797e4855d5f01
[clang-tidy] Support std::format and std::print in readability-redundant-string-cstr

std::format (C++20) and std::print (C++23) are perfectly happy to accept
std::string arguments. Converting them to C-style strings by calling
c_str() is unnecessary and may cause extra walking of the string to
determine its length.

Depends on D144216

Reviewed By: carlosgalvezp, PiotrZSL

Differential Revision: https://reviews.llvm.org/D143342
clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string
clang-tools-extra/test/clang-tidy/checkers/readability/redundant-string-cstr-format.cpp [new file with mode: 0644]