[clang-tools-extra] [clang-tidy] Add missing #include insertion in macros for modernize-use-std-format (PR #188247)

via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 24 06:47:41 PDT 2026


github-actions[bot] wrote:

<!--PREMERGE ADVISOR COMMENT: Windows-->
# :window: Windows x64 Test Results

* 3109 tests passed
* 29 tests skipped
* 1 test failed

## Failed Tests
(click on a test name to see its output)

### Clang Tools
<details>
<summary>Clang Tools.clang-tidy/checkers/modernize/use-std-format-macro.cpp</summary>

```
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
C:/Python312/python.exe C:/_work/llvm-project/llvm-project/clang-tools-extra/test/../test\clang-tidy\check_clang_tidy.py -std=c++20-or-later C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\modernize\use-std-format-macro.cpp modernize-use-std-format C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\modernize\Output\use-std-format-macro.cpp.tmp --    -config="{CheckOptions: {               modernize-use-std-format.StrFormatLikeFunctions: 'String::Printf',               modernize-use-std-format.ReplacementFormatFunction: 'fmt::format',               modernize-use-std-format.FormatHeader: '<fmt/format.h>'             }}"
# executed command: C:/Python312/python.exe 'C:/_work/llvm-project/llvm-project/clang-tools-extra/test/../test\clang-tidy\check_clang_tidy.py' -std=c++20-or-later 'C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\modernize\use-std-format-macro.cpp' modernize-use-std-format 'C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\modernize\Output\use-std-format-macro.cpp.tmp' -- '-config={CheckOptions: {               modernize-use-std-format.StrFormatLikeFunctions: '"'"'String::Printf'"'"',               modernize-use-std-format.ReplacementFormatFunction: '"'"'fmt::format'"'"',               modernize-use-std-format.FormatHeader: '"'"'<fmt/format.h>'"'"'             }}'
# .---command stdout------------
# | Running ['clang-tidy', '--experimental-custom-checks', 'C:\\_work\\llvm-project\\llvm-project\\build\\tools\\clang\\tools\\extra\\test\\clang-tidy\\checkers\\modernize\\Output\\use-std-format-macro.cpp.tmp.cpp', '-fix', '--checks=-*,modernize-use-std-format', "-config={CheckOptions: {               modernize-use-std-format.StrFormatLikeFunctions: 'String::Printf',               modernize-use-std-format.ReplacementFormatFunction: 'fmt::format',               modernize-use-std-format.FormatHeader: '<fmt/format.h>'             }}", '--', '-std=c++20', '-nostdinc++', '-isystem', 'C:\\_work\\llvm-project\\llvm-project\\clang-tools-extra\\test\\clang-tidy\\checkers\\Inputs\\Headers\\std']...
# | ------------------------ clang-tidy output -----------------------
# | 1 warning generated.
# | 
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\modernize\Output\use-std-format-macro.cpp.tmp.cpp:18:19: warning: use 'fmt::format' instead of 'Printf' [modernize-use-std-format]
# |    18 |   return WRAP_MSG(String::Printf("value %d", n));
# |       |                   ^~~~~~~~~~~~~~ ~~~~~~~~~~
# |       |                   fmt::format    "value {}"
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\modernize\Output\use-std-format-macro.cpp.tmp.cpp:18:19: note: FIX-IT applied suggested code changes
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\modernize\Output\use-std-format-macro.cpp.tmp.cpp:18:34: note: FIX-IT applied suggested code changes
# |    18 |   return WRAP_MSG(String::Printf("value %d", n));
# |       |                                  ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\modernize\Output\use-std-format-macro.cpp.tmp.cpp:15:23: note: expanded from macro 'WRAP_MSG'
# | clang-tidy applied 2 of 2 suggested fixes.
# | 
# |    15 | #define WRAP_MSG(msg) msg
# |       |                       ^
# | 
# | ------------------------------------------------------------------
# | diff -u C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\modernize\Output\use-std-format-macro.cpp.tmp.orig C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\modernize\Output\use-std-format-macro.cpp.tmp.cpp failed:
# | --- C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\modernize\Output\use-std-format-macro.cpp.tmp.orig	2026-03-24 13:46:47.369595500 +0000
# | +++ C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\modernize\Output\use-std-format-macro.cpp.tmp.cpp	2026-03-24 13:46:47.415477900 +0000
# | @@ -15,7 +15,7 @@
# |  #define WRAP_MSG(msg) msg
# | 
# |  
# | 
# |  std::string macro_argument_include(int n) {
# | 
# | -  return WRAP_MSG(String::Printf("value %d", n));
# | 
# | +  return WRAP_MSG(fmt::format("value {}", n));
# | 
# |    //
# | 
# |    //
# | 
# |  }
# | 
# | 
# | ------------------------------ Fixes -----------------------------
# | --- C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\modernize\Output\use-std-format-macro.cpp.tmp.orig	2026-03-24 13:46:47.369595500 +0000
# | +++ C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\modernize\Output\use-std-format-macro.cpp.tmp.cpp	2026-03-24 13:46:47.415477900 +0000
# | @@ -15,7 +15,7 @@
# |  #define WRAP_MSG(msg) msg
# | 
# |  
# | 
# |  std::string macro_argument_include(int n) {
# | 
# | -  return WRAP_MSG(String::Printf("value %d", n));
# | 
# | +  return WRAP_MSG(fmt::format("value {}", n));
# | 
# |    //
# | 
# |    //
# | 
# |  }
# | 
# | 
# | ------------------------------------------------------------------
# | FileCheck --input-file=C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\modernize\Output\use-std-format-macro.cpp.tmp.cpp C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\modernize\use-std-format-macro.cpp --check-prefixes=CHECK-FIXES --match-full-lines failed:
# | C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\modernize\use-std-format-macro.cpp:9:17: error: CHECK-FIXES: expected string not found in input
# | 
# | // CHECK-FIXES: #include <fmt/format.h>
# | 
# |                 ^
# | 
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\modernize\Output\use-std-format-macro.cpp.tmp.cpp:1:1: note: scanning from here
# | 
# | // RUN: %check_clang_tidy -std=c++20-or-later %s modernize-use-std-format %t -- \
# | 
# | ^
# | 
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\modernize\Output\use-std-format-macro.cpp.tmp.cpp:5:46: note: possible intended match here
# | 
# | // RUN: modernize-use-std-format.FormatHeader: '<fmt/format.h>' \
# | 
# |                                              ^
# | 
# | 
# | 
# | Input file: C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\modernize\Output\use-std-format-macro.cpp.tmp.cpp
# | 
# | Check file: C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\modernize\use-std-format-macro.cpp
# | 
# | 
# | 
# | -dump-input=help explains the following input dump.
# | 
# | 
# | 
# | Input was:
# | 
# | <<<<<<
# | 
# |            1: // RUN: %check_clang_tidy -std=c++20-or-later %s modernize-use-std-format %t -- \ 
# | 
# | check:9'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
# | 
# |            2: // RUN: -config="{CheckOptions: { \ 
# | 
# | check:9'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 
# |            3: // RUN: modernize-use-std-format.StrFormatLikeFunctions: 'String::Printf', \ 
# | 
# | check:9'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 
# |            4: // RUN: modernize-use-std-format.ReplacementFormatFunction: 'fmt::format', \ 
# | 
# | check:9'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 
# |            5: // RUN: modernize-use-std-format.FormatHeader: '<fmt/format.h>' \ 
# | 
# | check:9'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 
# | check:9'1                                                  ?                     possible intended match
# | 
# |            6: // RUN: }}" 
# | 
# | check:9'0     ~~~~~~~~~~~~
# | 
# |            7:  
# | 
# | check:9'0     ~
# | 
# |            8: #include <string> 
# | 
# | check:9'0     ~~~~~~~~~~~~~~~~~~
# | 
# |            9: // 
# | 
# | check:9'0     ~~~
# | 
# |           10:  
# | 
# | check:9'0     ~
# | 
# |            .
# | 
# |            .
# | 
# |            .
# | 
# | >>>>>>
# | 
# | 
# `-----------------------------
# .---command stderr------------
# | Traceback (most recent call last):
# |   File "C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\check_clang_tidy.py", line 554, in <module>
# |     main()
# |   File "C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\check_clang_tidy.py", line 550, in main
# |     CheckRunner(args, extra_args).run()
# |   File "C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\check_clang_tidy.py", line 432, in run
# |     self.check_fixes()
# |   File "C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\check_clang_tidy.py", line 327, in check_fixes
# |     try_run(
# |   File "C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\check_clang_tidy.py", line 64, in try_run
# |     process_output = subprocess.check_output(args, stderr=subprocess.STDOUT).decode(
# |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# |   File "c:\python312\Lib\subprocess.py", line 466, in check_output
# |     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
# |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# |   File "c:\python312\Lib\subprocess.py", line 571, in run
# |     raise CalledProcessError(retcode, process.args,
# | subprocess.CalledProcessError: Command '['FileCheck', '--input-file=C:\\_work\\llvm-project\\llvm-project\\build\\tools\\clang\\tools\\extra\\test\\clang-tidy\\checkers\\modernize\\Output\\use-std-format-macro.cpp.tmp.cpp', 'C:\\_work\\llvm-project\\llvm-project\\clang-tools-extra\\test\\clang-tidy\\checkers\\modernize\\use-std-format-macro.cpp', '--check-prefixes=CHECK-FIXES', '--match-full-lines']' returned non-zero exit status 1.
# `-----------------------------
# error: command failed with exit status: 1

--

```
</details>

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the `infrastructure` label.

https://github.com/llvm/llvm-project/pull/188247


More information about the cfe-commits mailing list