[clang-tidy] Fix width/precision argument order in modernize-use-std-print
authorMike Crowe <mac@mcrowe.com>
Mon, 3 Jul 2023 16:29:28 +0000 (16:29 +0000)
committerPiotr Zegar <me@piotrzegar.pl>
Mon, 3 Jul 2023 16:39:04 +0000 (16:39 +0000)
commit2806cf4b5430ad6d4d5aa2d501aea1de67272876
treec1312807e00100561e72b8a4f9ff729c3e314661
parenta2ff2921e84aa435e124ad275f70855a185cfb1c
[clang-tidy] Fix width/precision argument order in modernize-use-std-print

Victor Zverovich pointed out[1] that printf takes the field width and
precision arguments before the value to be printed whereas std::print
takes the value first (unless positional arguments are used.) Many of
the test cases in use-std-print.cpp were incorrect.

Teach the check to rotate the arguments when required to correct
this. Correct the test cases and add more.

[1] https://github.com/fmtlib/fmt/pull/3515#issuecomment-1615259893

Reviewed By: PiotrZSL

Differential Revision: https://reviews.llvm.org/D154283
clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp
clang-tools-extra/clang-tidy/utils/FormatStringConverter.h
clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print.cpp