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
85 lines
2.6 KiB
C++
85 lines
2.6 KiB
C++
// RUN: %check_clang_tidy %s llvm-formatv-string %t
|
|
|
|
namespace llvm {
|
|
|
|
template <typename... Ts>
|
|
void formatv(const char *Fmt, Ts &&...Vals) {}
|
|
|
|
template <typename... Ts>
|
|
void formatv(bool Validate, const char *Fmt, Ts &&...Vals) {}
|
|
|
|
} // namespace llvm
|
|
|
|
void correct() {
|
|
llvm::formatv("{0}", 1);
|
|
llvm::formatv("{0} {1}", 1, 2);
|
|
llvm::formatv("{0} {0}", 1);
|
|
llvm::formatv("{1} {0}", 1, 2);
|
|
llvm::formatv("{0,10}", 1);
|
|
llvm::formatv("{0,-10}", 1);
|
|
llvm::formatv("{0:x}", 1);
|
|
llvm::formatv("{0,10:x}", 1);
|
|
llvm::formatv("{0:$[,]}", 1);
|
|
llvm::formatv("{ 0 }", 1);
|
|
llvm::formatv("{ 0 :x}", 1);
|
|
llvm::formatv("{ 0 } { 1 }", 1, 2);
|
|
llvm::formatv("no replacements");
|
|
llvm::formatv("escaped {{ braces }}");
|
|
llvm::formatv("{}", 1);
|
|
llvm::formatv("{} {}", 1, 2);
|
|
llvm::formatv(false, "{0}", 1);
|
|
}
|
|
|
|
void too_few_args() {
|
|
llvm::formatv("{0}");
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: format string requires 1 argument, but 0 arguments were provided
|
|
|
|
llvm::formatv("{0} {1}", 1);
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: format string requires 2 arguments, but 1 argument was provided
|
|
|
|
llvm::formatv("{0} {1} {2}", 1, 2);
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: format string requires 3 arguments, but 2 arguments were provided
|
|
}
|
|
|
|
void too_many_args() {
|
|
llvm::formatv("{0}", 1, 2);
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: argument unused in format string
|
|
|
|
llvm::formatv("no replacements", 1);
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:36: warning: argument unused in format string
|
|
}
|
|
|
|
void mixed_indices() {
|
|
llvm::formatv("{} {1}", 1, 2);
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: format string mixes automatic and explicit indices
|
|
}
|
|
|
|
void holes_in_indices() {
|
|
llvm::formatv("{0} {2}", 1, 2, 3);
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: argument unused in format string
|
|
|
|
llvm::formatv("{2}", 1, 2, 3);
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: argument unused in format string
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:27: warning: argument unused in format string
|
|
|
|
llvm::formatv("{1}", 10, 20, 30);
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: argument unused in format string
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:32: warning: argument unused in format string
|
|
}
|
|
|
|
void non_literal_format_string(const char *fmt) {
|
|
// No warning for non-literal format strings.
|
|
llvm::formatv(fmt, 1, 2);
|
|
}
|
|
|
|
void bool_overload() {
|
|
llvm::formatv(false, "{0} {1}", 1, 2);
|
|
llvm::formatv(true, "{0}", 1, 2);
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: argument unused in format string
|
|
}
|
|
|
|
void invalid_index() {
|
|
llvm::formatv("{abc}", 1);
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid replacement index in format string
|
|
}
|