Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: llvmorg-21-init, llvmorg-19.1.7, llvmorg-19.1.6, llvmorg-19.1.5, llvmorg-19.1.4, llvmorg-19.1.3, llvmorg-19.1.2, llvmorg-19.1.1, llvmorg-19.1.0, llvmorg-19.1.0-rc4, llvmorg-19.1.0-rc3, llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init
# 666d2242 17-Jul-2024 Mike Crowe <mac@mcrowe.com>

[clang-tidy] Fix modernize-use-std-print/format for fmt (#99021)

When fixing #92896 in 0e62d5cf55479981da5e05e406bbca4afb3cdc4f (#94104)
I failed to spot that I'd broken converting from fmt::printf

[clang-tidy] Fix modernize-use-std-print/format for fmt (#99021)

When fixing #92896 in 0e62d5cf55479981da5e05e406bbca4afb3cdc4f (#94104)
I failed to spot that I'd broken converting from fmt::printf,
fmt::fprintf and fmt::sprintf in these checks since the format parameter
of those functions is not a simple character pointer.

The first part of the previous fix to avoid the assert and instead
produce an error message was sufficient. It was only the second part
that required the format parameter of the called function to be a simple
character pointer that was problematic. Let's remove that second part
and add the now-expected error messages to the lit tests along with
fixing the prototype for the fmt functions to more accurately reflect
the ones used by the fmt library so they are actually useful.

Fixes #92896

show more ...


Revision tags: llvmorg-18.1.8, llvmorg-18.1.7
# 0e62d5cf 03-Jun-2024 Mike Crowe <mac@mcrowe.com>

[clang-tidy] Fix assert in modernize-use-std-format/print (#94104)

Ensure that FormatStringConverter's constructor fails with a sensible
error message rather than asserting if the format string is

[clang-tidy] Fix assert in modernize-use-std-format/print (#94104)

Ensure that FormatStringConverter's constructor fails with a sensible
error message rather than asserting if the format string is not a narrow
string literal.

Also, ensure that we don't even get that far in modernize-use-std-print
and modernize-use-std-format by checking that the format string
parameter is a char pointer.

Fixes #92896

show more ...


Revision tags: llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init, llvmorg-17.0.6, llvmorg-17.0.5, llvmorg-17.0.4, llvmorg-17.0.3, llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0, llvmorg-17.0.0-rc4, llvmorg-17.0.0-rc3, llvmorg-17.0.0-rc2
# 1af159e9 07-Aug-2023 Piotr Zegar <me@piotrzegar.pl>

[clang-tidy][NFC] Update tests to CheckOptions using new syntax

This patch is just updating all test files to use the new syntax.
Fix for changes introduced after D130209 were created.


Revision tags: llvmorg-17.0.0-rc1, llvmorg-18-init
# b389a625 11-Jul-2023 Mike Crowe <mac@mcrowe.com>

[clang-tidy] Make MatchesAnyListedNameMatcher cope with unnamed Decl

If MatchesAnyListedNameMatcher::NameMatcher::match() is called in
MatchMode::MatchUnqualified mode with a NamedDecl that has no n

[clang-tidy] Make MatchesAnyListedNameMatcher cope with unnamed Decl

If MatchesAnyListedNameMatcher::NameMatcher::match() is called in
MatchMode::MatchUnqualified mode with a NamedDecl that has no name then
calling NamedDecl::getName() will assert with:
`Name.isIdentifier() && "Name is not a simple identifier"'

It seems unfair to force all matchers using
matchers::matchesAnyListedName to defend against this, particularly
since test cases are unlikely to provoke the problem. Let's just check
whether the identifier has a name before attempting to use it instead.

Add test case that reproduces the problem to the
use-std-print-custom.cpp lit check.

Reviewed By: PiotrZSL

Differential Revision: https://reviews.llvm.org/D154884

show more ...


# 09ed2102 28-Jun-2023 Mike Crowe <mac@mcrowe.com>

[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

[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

show more ...


# 43fa7ea9 27-Jun-2023 Piotr Zegar <me@piotrzegar.pl>

Revert "[clang-tidy] Fix modernize-use-std-print check when return value used"

This reverts commit 3e12b2e207cfa802937488a2c0b90d482eaf00a9.


# 3e12b2e2 27-Jun-2023 Mike Crowe <mac@mcrowe.com>

[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

[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

show more ...


# 83f875dc 26-Jun-2023 Mike Crowe <mac@mcrowe.com>

[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

[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

show more ...


# ec89cb9a 26-Jun-2023 Mike Crowe <mac@mcrowe.com>

[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

[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

show more ...


# 81418ada 25-Jun-2023 Mike Crowe <mac@mcrowe.com>

[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

[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

show more ...