[all-commits] [llvm/llvm-project] 2806cf: [clang-tidy] Fix width/precision argument order in...

Mike Crowe via All-commits all-commits at lists.llvm.org
Mon Jul 3 09:39:28 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2806cf4b5430ad6d4d5aa2d501aea1de67272876
  Author: Mike Crowe <mac at mcrowe.com>
  Date:   2023-07-03 (Mon, 03 Jul 2023)

  Changed paths:
    M clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp
    M clang-tools-extra/clang-tidy/utils/FormatStringConverter.h
    M clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print.cpp

  Log Message:
  [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

More information about the All-commits mailing list