1// RUN: %check_clang_tidy %s modernize-use-std-format %t -- \
2// RUN: -config="{CheckOptions: { \
3// RUN: modernize-use-std-format.StrictMode: true, \
4// RUN: modernize-use-std-format.StrFormatLikeFunctions: 'fmt::sprintf', \
5// RUN: modernize-use-std-format.ReplacementFormatFunction: 'fmt::format', \
6// RUN: modernize-use-std-format.FormatHeader: '<fmt/core.h>' \
7// RUN: }}" \
8// RUN: -- -isystem %clang_tidy_headers
9
10// CHECK-FIXES: #include <fmt/core.h>
11#include <string>
12
13namespace fmt
14{
15template <typename S, typename... T,
16 typename Char = char>
17std::basic_string<Char> sprintf(const S& fmt, const T&... args);
18} // namespace fmt
19
20std::string fmt_sprintf_simple() {
21 return fmt::sprintf(fmt: "Hello %s %d", args: "world", args: 42);
22 // CHECK-MESSAGES: [[@LINE-1]]:10: warning: use 'fmt::format' instead of 'sprintf' [modernize-use-std-format]
23 // CHECK-FIXES: return fmt::format("Hello {} {}", "world", 42);
24}
25

source code of clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format-fmt.cpp