[clang-tools-extra] [clang-tidy] Fix crash in `cppcoreguidelines-pro-type-member-init` with alias template in constructor initializer (PR #192786)

via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 18 04:59:11 PDT 2026


github-actions[bot] wrote:

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

* 3199 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/cppcoreguidelines/pro-type-member-init-no-crash.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 -expect-clang-tidy-error /home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-member-init-no-crash.cpp cppcoreguidelines-pro-type-member-init /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/cppcoreguidelines/Output/pro-type-member-init-no-crash.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 -expect-clang-tidy-error /home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-member-init-no-crash.cpp cppcoreguidelines-pro-type-member-init /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/cppcoreguidelines/Output/pro-type-member-init-no-crash.cpp.tmp
# .---command stdout------------
# | Running ['not', 'clang-tidy', '--experimental-custom-checks', '/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/cppcoreguidelines/Output/pro-type-member-init-no-crash.cpp.tmp.cpp', '-fix', '--checks=-*,cppcoreguidelines-pro-type-member-init', '--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 -----------------------
# | 1 warning and 2 errors generated.
# | Error while processing /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/cppcoreguidelines/Output/pro-type-member-init-no-crash.cpp.tmp.cpp.
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/cppcoreguidelines/Output/pro-type-member-init-no-crash.cpp.tmp.cpp:4:5: error: field has incomplete type 'X' [clang-diagnostic-error]
# |     4 |   X x;
# |       |     ^
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/cppcoreguidelines/Output/pro-type-member-init-no-crash.cpp.tmp.cpp:3:8: note: definition of 'X' is not complete until the closing '}'
# |     3 | struct X {
# |       |        ^
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/cppcoreguidelines/Output/pro-type-member-init-no-crash.cpp.tmp.cpp:12:20: error: base class has incomplete type [clang-diagnostic-error]
# |    12 |   class B : public NoCrash {
# |       |             ~~~~~~~^~~~~~~
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/cppcoreguidelines/Output/pro-type-member-init-no-crash.cpp.tmp.cpp:9:29: note: definition of 'NoCrash<T>' is not complete until the closing '}'
# |     9 | template <typename T> class NoCrash {
# |       |                             ^
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/cppcoreguidelines/Output/pro-type-member-init-no-crash.cpp.tmp.cpp:31:5: warning: constructor does not initialize these bases: Base [cppcoreguidelines-pro-type-member-init]
# |    31 |     X(INT i) : INT(i) {} // no crash
# |       |     ^
# |       |                Base(),
# | Found compiler errors, but -fix-errors was not specified.
# | Fixes have NOT been applied.
# | 
# | Found compiler error(s).
# | 
# | ------------------------------------------------------------------
# | ------------------------------ Fixes -----------------------------
# | 
# | ------------------------------------------------------------------
# | FileCheck -input-file=/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/cppcoreguidelines/Output/pro-type-member-init-no-crash.cpp.tmp.cpp.msg /home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-member-init-no-crash.cpp -check-prefixes=CHECK-MESSAGES -implicit-check-not={{warning|error}}: failed:
# | command line:1:22: error: IMPLICIT-CHECK-NOT: excluded string found in input
# | -implicit-check-not='{{warning|error}}:'
# |                      ^
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/cppcoreguidelines/Output/pro-type-member-init-no-crash.cpp.tmp.cpp.msg:15:186: note: found here
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/cppcoreguidelines/Output/pro-type-member-init-no-crash.cpp.tmp.cpp:31:5: warning: constructor does not initialize these bases: Base [cppcoreguidelines-pro-type-member-init]
# |                                                                                                                                                                                          ^~~~~~~~
# | 
# | Input file: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/cppcoreguidelines/Output/pro-type-member-init-no-crash.cpp.tmp.cpp.msg
# | Check file: /home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-member-init-no-crash.cpp
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |           .
# |           .
# |           .
# |          10:  12 | class B : public NoCrash { 
# |          11:  | ~~~~~~~^~~~~~~ 
# |          12: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/cppcoreguidelines/Output/pro-type-member-init-no-crash.cpp.tmp.cpp:9:29: note: definition of 'NoCrash<T>' is not complete until the closing '}' 
# |          13:  9 | template <typename T> class NoCrash { 
# |          14:  | ^ 
# |          15: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/clang/tools/extra/test/clang-tidy/checkers/cppcoreguidelines/Output/pro-type-member-init-no-crash.cpp.tmp.cpp:31:5: warning: constructor does not initialize these bases: Base [cppcoreguidelines-pro-type-member-init] 
# | not:imp1                                                                                                                                                                                              !~~~~~~~                                                                                             error: no match expected
# |          16:  31 | X(INT i) : INT(i) {} // no crash 
# |          17:  | ^ 
# |          18:  | Base(), 
# |          19: Found compiler errors, but -fix-errors was not specified. 
# |          20: Fixes have NOT been applied. 
# |          21:  
# |          22: Found compiler error(s). 
# | >>>>>>
# | 
# `-----------------------------
# .---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 433, in run
# |     self.check_messages(main_output)
# |   File "/home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/test/../test/clang-tidy/check_clang_tidy.py", line 358, in check_messages
# |     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/cppcoreguidelines/Output/pro-type-member-init-no-crash.cpp.tmp.cpp.msg', '/home/gha/actions-runner/_work/llvm-project/llvm-project/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-member-init-no-crash.cpp', '-check-prefixes=CHECK-MESSAGES', '-implicit-check-not={{warning|error}}:']' 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/192786


More information about the cfe-commits mailing list