[clang-tidy] Fix modernize-use-std-print check when return value used
authorMike Crowe <mac@mcrowe.com>
Tue, 27 Jun 2023 16:35:22 +0000 (16:35 +0000)
committerPiotr Zegar <me@piotrzegar.pl>
Tue, 27 Jun 2023 17:23:52 +0000 (17:23 +0000)
commit3e12b2e207cfa802937488a2c0b90d482eaf00a9
tree4c8d9165ce3cf08d2994cdd196e8a120db363418
parent76a27f3a32f619d386fb8efa1563ba21b76e9170
[clang-tidy] Fix modernize-use-std-print check when return value used

The initial implementation of the modernize-use-std-print check was
capable of converting calls to printf (etc.) which used the return value
to calls to std::print which has no return value, thus breaking the
code.

Use code inspired by the implementation of bugprone-unused-return-value
check to ignore cases where the return value is used. Add appropriate
lit test cases and documentation.

Reviewed By: PiotrZSL

Differential Revision: https://reviews.llvm.org/D153860
clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print-absl.cpp
clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print-custom.cpp
clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print.cpp