[clang-tools-extra] [clang-tidy] Fix unique-ptr-array-mismatch crash by safely managing const qualifiers (PR #219050)

via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 26 21:55:11 PDT 2026


github-actions[bot] wrote:

<!--PREMERGE ADVISOR COMMENT: Linux-->
# :penguin: Linux x64 Test Results

* 3399 tests passed
* 8 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/bugprone/unique-ptr-array-mismatch.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 /home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/test/clang-tidy/checkers/bugprone/unique-ptr-array-mismatch.cpp bugprone-unique-ptr-array-mismatch /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/bugprone/Output/unique-ptr-array-mismatch.cpp.tmp
# 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 /home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/test/clang-tidy/checkers/bugprone/unique-ptr-array-mismatch.cpp bugprone-unique-ptr-array-mismatch /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/bugprone/Output/unique-ptr-array-mismatch.cpp.tmp
# .---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/bugprone/Output/unique-ptr-array-mismatch.cpp.tmp.cpp', '-fix', '--checks=-*,bugprone-unique-ptr-array-mismatch', '--config={}', '--', '-std=c++11', '-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 -----------------------
# | 
# | ------------------------------------------------------------------
# | ------------------------------ Fixes -----------------------------
# | 
# | ------------------------------------------------------------------
# | FileCheck --input-file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/bugprone/Output/unique-ptr-array-mismatch.cpp.tmp.cpp /home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/test/clang-tidy/checkers/bugprone/unique-ptr-array-mismatch.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/bugprone/unique-ptr-array-mismatch.cpp:14:18: error: CHECK-FIXES: expected string not found in input
# |  // CHECK-FIXES: std::unique_ptr<int[]> P2{new int[10]};
# |                  ^
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/bugprone/Output/unique-ptr-array-mismatch.cpp.tmp.cpp:1:1: note: scanning from here
# | // RUN: %check_clang_tidy %s bugprone-unique-ptr-array-mismatch %t
# | ^
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/bugprone/Output/unique-ptr-array-mismatch.cpp.tmp.cpp:12:2: note: possible intended match here
# |  std::unique_ptr<int> P2{new int[10]};
# |  ^
# | 
# | Input file: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/bugprone/Output/unique-ptr-array-mismatch.cpp.tmp.cpp
# | Check file: /home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/test/clang-tidy/checkers/bugprone/unique-ptr-array-mismatch.cpp
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             1: // RUN: %check_clang_tidy %s bugprone-unique-ptr-array-mismatch %t 
# | check:14'0    {                                                                     search range start (exclusive)
# | check:14'1                                                                          error: no match found in search range
# |             2:  
# |             3: #include <memory> 
# |             4:  
# |             5: struct A {}; 
# |             6:  
# |             7: using PtrT = std::unique_ptr<A>; 
# |             8: using PtrTArr = std::unique_ptr<A[]>; 
# |             9:  
# |            10: void f1() { 
# |            11:  std::unique_ptr<int> P1{new int}; 
# |            12:  std::unique_ptr<int> P2{new int[10]}; 
# | check:14'2      ?                                       possible intended match
# |            13:  // 
# |            14:  // 
# |            15:  // clang-format off 
# |            16:  std::unique_ptr< int > P3{new int[10]}; 
# |            17:  // 
# |             .
# |             .
# |             .
# |           101:  std::unique_ptr<char> CHAR_PTR_VAR(P2); 
# |           102:  // 
# |           103:  // 
# |           104:  CHAR_PTR_INIT(P3, new char[10]); 
# |           105:  // 
# |           106: } 
# | check:14'3       } search range end (exclusive)
# | >>>>>>
# | 
# `-----------------------------
# .---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 576, 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 572, 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 436, 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 331, 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 68, 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/bugprone/Output/unique-ptr-array-mismatch.cpp.tmp.cpp', '/home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/test/clang-tidy/checkers/bugprone/unique-ptr-array-mismatch.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/219050


More information about the cfe-commits mailing list