[PATCH] D154283: [clang-tidy] Fix width/precision argument order in modernize-use-std-print

Mike Crowe via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 1 09:42:58 PDT 2023


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

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154283

Files:
  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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154283.536533.patch
Type: text/x-patch
Size: 9002 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230701/a8142dde/attachment.bin>


More information about the cfe-commits mailing list