[clang-tidy] Fix modernize-use-std-print check when return value used
authorMike Crowe <mac@mcrowe.com>
Wed, 28 Jun 2023 15:36:42 +0000 (15:36 +0000)
committerPiotr Zegar <me@piotrzegar.pl>
Thu, 29 Jun 2023 14:00:08 +0000 (14:00 +0000)
commit09ed2102eab5d3d3786046009ff0d6724118b76b
tree1572e43f2fa30f3407dd4360f53c8dc1076f8205
parent4546015f867ac19823116374bb1fb21f27bd2447
[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