[clang-tools-extra] [clang-tidy] suggest fix it hints for string concat (PR #188430)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 26 08:59:14 PDT 2026
github-actions[bot] wrote:
<!--PREMERGE ADVISOR COMMENT: Windows-->
# :window: Windows x64 Test Results
* 3109 tests passed
* 30 tests skipped
* 2 tests failed
## Failed Tests
(click on a test name to see its output)
### Clang Tools
<details>
<summary>Clang Tools.clang-tidy/checkers/performance/inefficient-string-concatenation-strict.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 C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\performance\inefficient-string-concatenation-strict.cpp performance-inefficient-string-concatenation C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation-strict.cpp.tmp -- -config="{CheckOptions: {performance-inefficient-string-concatenation.StrictMode: true}}"
# executed command: C:/Python312/python.exe 'C:/_work/llvm-project/llvm-project/clang-tools-extra/test/../test\clang-tidy\check_clang_tidy.py' 'C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\performance\inefficient-string-concatenation-strict.cpp' performance-inefficient-string-concatenation 'C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation-strict.cpp.tmp' -- '-config={CheckOptions: {performance-inefficient-string-concatenation.StrictMode: true}}'
# .---command stdout------------
# | Running ['clang-tidy', '--experimental-custom-checks', 'C:\\_work\\llvm-project\\llvm-project\\build\\tools\\clang\\tools\\extra\\test\\clang-tidy\\checkers\\performance\\Output\\inefficient-string-concatenation-strict.cpp.tmp.cpp', '-fix', '--checks=-*,performance-inefficient-string-concatenation', '-config={CheckOptions: {performance-inefficient-string-concatenation.StrictMode: true}}', '--', '-std=c++11', '-nostdinc++', '-isystem', 'C:\\_work\\llvm-project\\llvm-project\\clang-tools-extra\\test\\clang-tidy\\checkers\\Inputs\\Headers\\std']...
# | ------------------------ clang-tidy output -----------------------
# | 2 warnings generated.
# |
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation-strict.cpp.tmp.cpp:9:10: warning: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation]
# | 9 | mystr1 = mystr1 + mystr2;
# | | ~~~~~~~^~~~~~~~~~~~~~~~~
# | | mystr1 += mystr2
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation-strict.cpp.tmp.cpp:9:3: note: FIX-IT applied suggested code changes
# | 9 | mystr1 = mystr1 + mystr2;
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation-strict.cpp.tmp.cpp:12:21: warning: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation]
# | clang-tidy applied 1 of 1 suggested fixes.
# |
# | 12 | f(mystr1 + mystr2 + mystr1);
# | | ^
# |
# | ------------------------------------------------------------------
# | diff -u C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation-strict.cpp.tmp.orig C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation-strict.cpp.tmp.cpp failed:
# | --- C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation-strict.cpp.tmp.orig 2026-03-26 15:57:52.137809100 +0000
# | +++ C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation-strict.cpp.tmp.cpp 2026-03-26 15:57:52.201281300 +0000
# | @@ -6,7 +6,7 @@
# |
# |
# | int main() {
# |
# | std::string mystr1, mystr2;
# |
# | - mystr1 = mystr1 + mystr2;
# |
# | + mystr1 += mystr2;
# |
# | //
# |
# |
# |
# | f(mystr1 + mystr2 + mystr1);
# |
# |
# | ------------------------------ Fixes -----------------------------
# | --- C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation-strict.cpp.tmp.orig 2026-03-26 15:57:52.137809100 +0000
# | +++ C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation-strict.cpp.tmp.cpp 2026-03-26 15:57:52.201281300 +0000
# | @@ -6,7 +6,7 @@
# |
# |
# | int main() {
# |
# | std::string mystr1, mystr2;
# |
# | - mystr1 = mystr1 + mystr2;
# |
# | + mystr1 += mystr2;
# |
# | //
# |
# |
# |
# | f(mystr1 + mystr2 + mystr1);
# |
# |
# | ------------------------------------------------------------------
# | FileCheck -input-file=C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation-strict.cpp.tmp.cpp.msg C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\performance\inefficient-string-concatenation-strict.cpp -check-prefixes=CHECK-MESSAGES -implicit-check-not={{warning|error}}: failed:
# | C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\performance\inefficient-string-concatenation-strict.cpp:10:21: error: CHECK-MESSAGES: expected string not found in input
# |
# | // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation]
# |
# | ^
# |
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation-strict.cpp.tmp.cpp.msg:1:1: note: scanning from here
# |
# | 2 warnings generated.
# |
# | ^
# |
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation-strict.cpp.tmp.cpp.msg:1:1: note: with "@LINE-1" equal to "9"
# |
# | 2 warnings generated.
# |
# | ^
# |
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation-strict.cpp.tmp.cpp.msg:2:163: note: possible intended match here
# |
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation-strict.cpp.tmp.cpp:9:10: warning: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation]
# |
# | ^
# |
# |
# |
# | Input file: C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation-strict.cpp.tmp.cpp.msg
# |
# | Check file: C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\performance\inefficient-string-concatenation-strict.cpp
# |
# |
# |
# | -dump-input=help explains the following input dump.
# |
# |
# |
# | Input was:
# |
# | <<<<<<
# |
# | 1: 2 warnings generated.
# |
# |
# | check:10'0 X~~~~~~~~~~~~~~~~~~~~~~ error: no match found
# |
# | check:10'1 with "@LINE-1" equal to "9"
# |
# | 2: C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation-strict.cpp.tmp.cpp:9:10: warning: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation]
# |
# | check:10'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
# | check:10'2 ? possible intended match
# |
# | 3: 9 | mystr1 = mystr1 + mystr2;
# |
# | check:10'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
# | 4: | ~~~~~~~^~~~~~~~~~~~~~~~~
# |
# | check:10'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
# | 5: | mystr1 += mystr2
# |
# | check:10'0 ~~~~~~~~~~~~~~~~~~~~
# |
# | 6: C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation-strict.cpp.tmp.cpp:9:3: note: FIX-IT applied suggested code changes
# |
# | check:10'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
# | 7: 9 | mystr1 = mystr1 + mystr2;
# |
# | check:10'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 433, in run
# | self.check_messages(main_output)
# | File "C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\check_clang_tidy.py", line 358, in check_messages
# | 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\\performance\\Output\\inefficient-string-concatenation-strict.cpp.tmp.cpp.msg', 'C:\\_work\\llvm-project\\llvm-project\\clang-tools-extra\\test\\clang-tidy\\checkers\\performance\\inefficient-string-concatenation-strict.cpp', '-check-prefixes=CHECK-MESSAGES', '-implicit-check-not={{warning|error}}:']' returned non-zero exit status 1.
# `-----------------------------
# error: command failed with exit status: 1
--
```
</details>
<details>
<summary>Clang Tools.clang-tidy/checkers/performance/inefficient-string-concatenation.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 C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\performance\inefficient-string-concatenation.cpp performance-inefficient-string-concatenation C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation.cpp.tmp
# executed command: C:/Python312/python.exe 'C:/_work/llvm-project/llvm-project/clang-tools-extra/test/../test\clang-tidy\check_clang_tidy.py' 'C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\performance\inefficient-string-concatenation.cpp' performance-inefficient-string-concatenation 'C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation.cpp.tmp'
# .---command stdout------------
# | Running ['clang-tidy', '--experimental-custom-checks', 'C:\\_work\\llvm-project\\llvm-project\\build\\tools\\clang\\tools\\extra\\test\\clang-tidy\\checkers\\performance\\Output\\inefficient-string-concatenation.cpp.tmp.cpp', '-fix', '--checks=-*,performance-inefficient-string-concatenation', '--config={}', '--', '-std=c++11', '-nostdinc++', '-isystem', 'C:\\_work\\llvm-project\\llvm-project\\clang-tools-extra\\test\\clang-tidy\\checkers\\Inputs\\Headers\\std']...
# | clang-tidy --experimental-custom-checks C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation.cpp.tmp.cpp -fix --checks=-*,performance-inefficient-string-concatenation --config={} -- -std=c++11 -nostdinc++ -isystem C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\Inputs\Headers\std failed:
# | 7 warnings and 3 errors generated.
# |
# | Error while processing C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation.cpp.tmp.cpp.
# |
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation.cpp.tmp.cpp:14:23: warning: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation]
# | 14 | f(mystr1 + mystr2 + mystr1);
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation.cpp.tmp.cpp:16:12: warning: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation]
# | 16 | mystr1 = mystr1 + mystr2;
# | | ~~~~~~~^~~~~~~~~~~~~~~~~
# | | mystr1 += mystr2
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation.cpp.tmp.cpp:19:30: warning: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation]
# | 19 | mystr1 = mystr2 + mystr2 + mystr2;
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation.cpp.tmp.cpp:21:12: warning: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation]
# | 21 | mystr1 = mystr2 + mystr1;
# | | ~~~~~~~^~~~~~~~~~~~~~~~~
# | | mystr1 += mystr2
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation.cpp.tmp.cpp:24:13: warning: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation]
# | 24 | mywstr1 = mywstr2 + mywstr1;
# | | ~~~~~~~~^~~~~~~~~~~~~~~~~~~
# | | mywstr1 += mywstr2
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation.cpp.tmp.cpp:27:33: warning: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation]
# | 27 | mywstr1 = mywstr2 + mywstr2 + mywstr2;
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation.cpp.tmp.cpp:29:16: warning: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation]
# | 29 | myautostr1 = myautostr1 + myautostr2;
# | | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | | myautostr1 += myautostr2
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation.cpp.tmp.cpp:34:4: error: unterminated /* comment [clang-diagnostic-error]
# | 34 | /* mystr1 = mystr1 + mystr2 + mystr2;
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation.cpp.tmp.cpp:53:2: error: expected '}' [clang-diagnostic-error]
# | 53 | }
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\performance\Output\inefficient-string-concatenation.cpp.tmp.cpp:13:32: note: to match this '{'
# | 13 | for (int i = 0; i < 10; ++i) {
# | | ^
# | Found compiler errors, but -fix-errors was not specified.
# |
# | Fixes have NOT been applied.
# |
# |
# |
# | Found compiler error(s).
# |
# |
# `-----------------------------
# .---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 426, in run
# | clang_tidy_output = self.run_clang_tidy()
# | ^^^^^^^^^^^^^^^^^^^^^
# | File "C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\check_clang_tidy.py", line 289, in run_clang_tidy
# | clang_tidy_output = try_run(args)
# | ^^^^^^^^^^^^^
# | 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 '['clang-tidy', '--experimental-custom-checks', 'C:\\_work\\llvm-project\\llvm-project\\build\\tools\\clang\\tools\\extra\\test\\clang-tidy\\checkers\\performance\\Output\\inefficient-string-concatenation.cpp.tmp.cpp', '-fix', '--checks=-*,performance-inefficient-string-concatenation', '--config={}', '--', '-std=c++11', '-nostdinc++', '-isystem', 'C:\\_work\\llvm-project\\llvm-project\\clang-tools-extra\\test\\clang-tidy\\checkers\\Inputs\\Headers\\std']' 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/188430
More information about the cfe-commits
mailing list