[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: Linux-->
# :penguin: Linux x64 Test Results
* 3172 tests passed
* 7 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
/usr/bin/python3 /home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/test/../test/clang-tidy/check_clang_tidy.py -std=c++20-or-later /home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format-macro.cpp modernize-use-std-format /home/gha/actions-runner/_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: /usr/bin/python3 /home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/test/../test/clang-tidy/check_clang_tidy.py -std=c++20-or-later /home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format-macro.cpp modernize-use-std-format /home/gha/actions-runner/_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', '/home/gha/actions-runner/_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', '/home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/test/../test/clang-tidy/checkers/Inputs/Headers/std']...
# | ------------------------ clang-tidy output -----------------------
# | 1 warning generated.
# | /home/gha/actions-runner/_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 {}"
# | /home/gha/actions-runner/_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
# | /home/gha/actions-runner/_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));
# | | ^
# | /home/gha/actions-runner/_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 /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/modernize/Output/use-std-format-macro.cpp.tmp.orig /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/modernize/Output/use-std-format-macro.cpp.tmp.cpp failed:
# | --- /home/gha/actions-runner/_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:41:23.781263239 +0000
# | +++ /home/gha/actions-runner/_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:41:23.795263400 +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 -----------------------------
# | --- /home/gha/actions-runner/_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:41:23.781263239 +0000
# | +++ /home/gha/actions-runner/_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:41:23.795263400 +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=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/modernize/Output/use-std-format-macro.cpp.tmp.cpp /home/gha/actions-runner/_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:
# | /home/gha/actions-runner/_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>
# | ^
# | /home/gha/actions-runner/_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 -- \
# | ^
# | /home/gha/actions-runner/_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: /home/gha/actions-runner/_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: /home/gha/actions-runner/_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 "/home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/test/../test/clang-tidy/check_clang_tidy.py", line 554, in <module>
# | main()
# | File "/home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/test/../test/clang-tidy/check_clang_tidy.py", line 550, in main
# | CheckRunner(args, extra_args).run()
# | File "/home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/test/../test/clang-tidy/check_clang_tidy.py", line 432, in run
# | self.check_fixes()
# | File "/home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/test/../test/clang-tidy/check_clang_tidy.py", line 327, in check_fixes
# | try_run(
# | File "/home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/test/../test/clang-tidy/check_clang_tidy.py", line 64, in try_run
# | process_output = subprocess.check_output(args, stderr=subprocess.STDOUT).decode(
# | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# | File "/usr/lib/python3.12/subprocess.py", line 466, in check_output
# | return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
# | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# | File "/usr/lib/python3.12/subprocess.py", line 571, in run
# | raise CalledProcessError(retcode, process.args,
# | subprocess.CalledProcessError: Command '['FileCheck', '--input-file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/modernize/Output/use-std-format-macro.cpp.tmp.cpp', '/home/gha/actions-runner/_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