[all-commits] [llvm/llvm-project] 2ae8a4: [ASTMatchers] Add argumentCountAtLeast narrowing m...
Mike Crowe via All-commits
all-commits at lists.llvm.org
Sun Jun 25 11:43:35 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 2ae8a4a17888f739c1082f52eed56887c2004908
https://github.com/llvm/llvm-project/commit/2ae8a4a17888f739c1082f52eed56887c2004908
Author: Mike Crowe <mac at mcrowe.com>
Date: 2023-06-25 (Sun, 25 Jun 2023)
Changed paths:
M clang/docs/LibASTMatchersReference.html
M clang/include/clang/ASTMatchers/ASTMatchers.h
M clang/lib/ASTMatchers/Dynamic/Registry.cpp
M clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
Log Message:
-----------
[ASTMatchers] Add argumentCountAtLeast narrowing matcher
This will be used by the modernize-use-std-print clang-tidy check and
related checks later.
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D153716
Commit: 81418ada06abbeba9fd0ea17282cce542cd07706
https://github.com/llvm/llvm-project/commit/81418ada06abbeba9fd0ea17282cce542cd07706
Author: Mike Crowe <mac at mcrowe.com>
Date: 2023-06-25 (Sun, 25 Jun 2023)
Changed paths:
M clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
M clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
A clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
A clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.h
M clang-tools-extra/clang-tidy/utils/CMakeLists.txt
A clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp
A clang-tools-extra/clang-tidy/utils/FormatStringConverter.h
M clang-tools-extra/docs/ReleaseNotes.rst
M clang-tools-extra/docs/clang-tidy/checks/list.rst
A clang-tools-extra/docs/clang-tidy/checks/modernize/use-std-print.rst
A clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/cstddef
A clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/cstdint
A clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/cstdio
M clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/stdio.h
M clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string.h
A clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print-absl.cpp
A clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print-custom.cpp
A clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print-fmt.cpp
A clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print.cpp
Log Message:
-----------
[clang-tidy] Add modernize-printf-to-std-print check
Add FormatStringConverter utility class that is capable of converting
printf-style format strings into std::print-style format strings along
with recording a set of casts to wrap the arguments as required and
removing now-unnecessary calls to std::string::c_str() and
std::string::data()
Use FormatStringConverter to implement a new clang-tidy check that is
capable of converting calls to printf, fprintf, absl::PrintF,
absl::FPrintF, or any functions configured by an option to calls to
std::print and std::println, or other functions configured by options.
In other words, the check turns:
fprintf(stderr, "The %s is %3d\n", description.c_str(), value);
into:
std::println(stderr, "The {} is {:3}", description, value);
if it can.
std::print and std::println can do almost anything that standard printf
can, but the conversion has some some limitations that are described in
the documentation. If conversion is not possible then the call remains
unchanged.
Depends on D153716
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D149280
Compare: https://github.com/llvm/llvm-project/compare/b851308b870a...81418ada06ab
More information about the All-commits
mailing list