CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
70 lines
3.3 KiB
C++
70 lines
3.3 KiB
C++
// RUN: %check_clang_tidy -check-suffixes=,STRICT \
|
|
// RUN: -std=c++20-or-later %s modernize-use-std-format %t -- \
|
|
// RUN: -config="{CheckOptions: { \
|
|
// RUN: modernize-use-std-format.StrictMode: true, \
|
|
// RUN: modernize-use-std-format.StrFormatLikeFunctions: '::strprintf; mynamespace::strprintf2; any_format_type_strprintf', \
|
|
// RUN: modernize-use-std-format.ReplacementFormatFunction: 'fmt::format', \
|
|
// RUN: modernize-use-std-format.FormatHeader: '<fmt/core.h>' \
|
|
// RUN: }}"
|
|
// RUN: %check_clang_tidy -check-suffixes=,NOTSTRICT \
|
|
// RUN: -std=c++20-or-later %s modernize-use-std-format %t -- \
|
|
// RUN: -config="{CheckOptions: { \
|
|
// RUN: modernize-use-std-format.StrFormatLikeFunctions: '::strprintf; mynamespace::strprintf2; any_format_type_strprintf', \
|
|
// RUN: modernize-use-std-format.ReplacementFormatFunction: 'fmt::format', \
|
|
// RUN: modernize-use-std-format.FormatHeader: '<fmt/core.h>' \
|
|
// RUN: }}"
|
|
#include <cstdio>
|
|
#include <string>
|
|
// CHECK-FIXES: #include <fmt/core.h>
|
|
|
|
std::string strprintf(const char *, ...);
|
|
|
|
namespace mynamespace {
|
|
std::string strprintf2(const char *, ...);
|
|
}
|
|
|
|
std::string strprintf_test(const std::string &name, double value) {
|
|
return strprintf("'%s'='%f'\n", name.c_str(), value);
|
|
// CHECK-MESSAGES: [[@LINE-1]]:10: warning: use 'fmt::format' instead of 'strprintf' [modernize-use-std-format]
|
|
// CHECK-FIXES: return fmt::format("'{}'='{:f}'\n", name, value);
|
|
|
|
return mynamespace::strprintf2("'%s'='%f'\n", name.c_str(), value);
|
|
// CHECK-MESSAGES: [[@LINE-1]]:10: warning: use 'fmt::format' instead of 'strprintf2' [modernize-use-std-format]
|
|
// CHECK-FIXES: return fmt::format("'{}'='{:f}'\n", name, value);
|
|
}
|
|
|
|
std::string StrFormat_strict_conversion() {
|
|
const unsigned char uc = 'A';
|
|
return strprintf("Integer %hhd from unsigned char\n", uc);
|
|
// CHECK-MESSAGES: [[@LINE-1]]:10: warning: use 'fmt::format' instead of 'strprintf' [modernize-use-std-format]
|
|
// CHECK-FIXES-NOTSTRICT: return fmt::format("Integer {} from unsigned char\n", uc);
|
|
// CHECK-FIXES-STRICT: return fmt::format("Integer {} from unsigned char\n", static_cast<signed char>(uc));
|
|
}
|
|
|
|
// Ensure that MatchesAnyListedRegexNameMatcher::NameMatcher::match() can cope with a
|
|
// NamedDecl that has no name when we're trying to match unqualified_strprintf.
|
|
std::string A(const std::string &in)
|
|
{
|
|
return "_" + in;
|
|
}
|
|
|
|
// Issue #92896: Ensure that the check doesn't assert if the argument is
|
|
// promoted to something that isn't a string.
|
|
struct S {
|
|
S(...);
|
|
};
|
|
std::string any_format_type_strprintf(const S &, ...);
|
|
|
|
void unsupported_format_parameter_types()
|
|
{
|
|
// No fixes here because the format parameter of the function called is not a
|
|
// string.
|
|
auto s1 = any_format_type_strprintf(L"");
|
|
auto s2 = any_format_type_strprintf(42);
|
|
|
|
// But if we do pass a character string then that ought to be acceptable.
|
|
auto s3 = any_format_type_strprintf("Hello %s", "world");
|
|
// CHECK-MESSAGES: [[@LINE-1]]:13: warning: use 'fmt::format' instead of 'any_format_type_strprintf' [modernize-use-std-format]
|
|
// CHECK-FIXES: auto s3 = fmt::format("Hello {}", "world");
|
|
}
|