[clang-tools-extra] [clang-tidy] Fix false positive in readability-redundant-preprocessor for builtin checks (PR #181734)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 16 12:09:33 PST 2026
github-actions[bot] wrote:
<!--PREMERGE ADVISOR COMMENT: Windows-->
# :window: Windows x64 Test Results
* 3052 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/readability/redundant-preprocessor.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\readability\redundant-preprocessor.cpp readability-redundant-preprocessor C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp -- -- -I C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\readability
# 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\readability\redundant-preprocessor.cpp' readability-redundant-preprocessor 'C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp' -- -- -I 'C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\readability'
# .---command stdout------------
# | Running ['clang-tidy', '--experimental-custom-checks', 'C:\\_work\\llvm-project\\llvm-project\\build\\tools\\clang\\tools\\extra\\test\\clang-tidy\\checkers\\readability\\Output\\redundant-preprocessor.cpp.tmp.cpp', '-fix', '--checks=-*,readability-redundant-preprocessor', '--config={}', '--', '-I', 'C:\\_work\\llvm-project\\llvm-project\\clang-tools-extra\\test\\clang-tidy\\checkers\\readability', '-std=c++11', '-nostdinc++']...
# | ------------------------ clang-tidy output -----------------------
# | 9 warnings generated.
# |
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp:6:2: warning: nested redundant #ifndef; consider removing it [readability-redundant-preprocessor]
# | 6 | #ifndef FOO
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp:4:2: note: previous #ifndef was here
# | 4 | #ifndef FOO
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp:15:2: warning: nested redundant #ifdef; consider removing it [readability-redundant-preprocessor]
# | 15 | #ifdef FOO
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp:13:2: note: previous #ifndef was here
# | 13 | #ifndef FOO
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp:45:2: warning: nested redundant #if; consider removing it [readability-redundant-preprocessor]
# | 45 | #if FOO == 4
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp:43:2: note: previous #if was here
# | 43 | #if FOO == 4
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp:53:2: warning: nested redundant #if; consider removing it [readability-redundant-preprocessor]
# | 53 | #if FOO == 3 + 1
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp:51:2: note: previous #if was here
# | 51 | #if FOO == 3 + 1
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp:62:2: warning: nested redundant #if; consider removing it [readability-redundant-preprocessor]
# | 62 | #if FOO == \
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp:59:2: note: previous #if was here
# | 59 | #if FOO == \
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp:95:4: warning: nested redundant #if; consider removing it [readability-redundant-preprocessor]
# | 95 | # if defined(FOO)
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp:93:2: note: previous #if was here
# | 93 | #if defined(FOO)
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp:117:4: warning: nested redundant #if; consider removing it [readability-redundant-preprocessor]
# | 117 | # if __has_builtin(__remove_cvref)
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp:115:2: note: previous #if was here
# | 115 | #if __has_builtin(__remove_cvref)
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp:149:4: warning: nested redundant #ifdef; consider removing it [readability-redundant-preprocessor]
# | 149 | # ifdef MACRO1
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp:147:2: note: previous #ifdef was here
# | 147 | #ifdef MACRO1
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp:164:4: warning: nested redundant #ifndef; consider removing it [readability-redundant-preprocessor]
# | 164 | # ifndef MACRO3
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp:162:2: note: previous #ifndef was here
# | 162 | #ifndef MACRO3
# | | ^
# |
# | ------------------------------------------------------------------
# | ------------------------------ Fixes -----------------------------
# |
# | ------------------------------------------------------------------
# | FileCheck -input-file=C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp.notes C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\readability\redundant-preprocessor.cpp -check-prefixes=CHECK-NOTES -implicit-check-not={{note|warning|error}}: failed:
# | C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\readability\redundant-preprocessor.cpp:137:17: error: CHECK-NOTES: expected string not found in input
# |
# | // CHECK-NOTES: [[@LINE+1]]:4: warning: nested redundant #if; consider removing it [readability-redundant-preprocessor]
# |
# | ^
# |
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp.notes:41:179: note: scanning from here
# |
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp:115:2: note: previous #if was here
# |
# | ^
# |
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp.notes:41:179: note: with "@LINE+1" equal to "138"
# |
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp:115:2: note: previous #if was here
# |
# | ^
# |
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp.notes:44:148: note: possible intended match here
# |
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp:149:4: warning: nested redundant #ifdef; consider removing it [readability-redundant-preprocessor]
# |
# | ^
# |
# |
# |
# | Input file: C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp.notes
# |
# | Check file: C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\readability\redundant-preprocessor.cpp
# |
# |
# |
# | -dump-input=help explains the following input dump.
# |
# |
# |
# | Input was:
# |
# | <<<<<<
# |
# | .
# |
# | .
# |
# | .
# |
# | 36: 93 | #if defined(FOO)
# |
# | 37: | ^
# |
# | 38: C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp:117:4: warning: nested redundant #if; consider removing it [readability-redundant-preprocessor]
# |
# | 39: 117 | # if __has_builtin(__remove_cvref)
# |
# | 40: | ^
# |
# | 41: C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp:115:2: note: previous #if was here
# |
# | check:137'0 X error: no match found
# |
# | check:137'1 with "@LINE+1" equal to "138"
# |
# | 42: 115 | #if __has_builtin(__remove_cvref)
# |
# | check:137'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
# | 43: | ^
# |
# | check:137'0 ~~~~~
# |
# | 44: C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp:149:4: warning: nested redundant #ifdef; consider removing it [readability-redundant-preprocessor]
# |
# | check:137'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
# | check:137'2 ? possible intended match
# |
# | 45: 149 | # ifdef MACRO1
# |
# | check:137'0 ~~~~~~~~~~~~~~~~~~~~~~
# |
# | 46: | ^
# |
# | check:137'0 ~~~~~
# |
# | 47: C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\redundant-preprocessor.cpp.tmp.cpp:147:2: note: previous #ifdef was here
# |
# | check:137'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
# | 48: 147 | #ifdef MACRO1
# |
# | check:137'0 ~~~~~~~~~~~~~~~~~~~~~
# |
# | 49: | ^
# |
# | check:137'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 546, in <module>
# | main()
# | File "C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\check_clang_tidy.py", line 542, 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
# | self.check_notes(main_output)
# | File "C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\check_clang_tidy.py", line 369, in check_notes
# | 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\\readability\\Output\\redundant-preprocessor.cpp.tmp.cpp.notes', 'C:\\_work\\llvm-project\\llvm-project\\clang-tools-extra\\test\\clang-tidy\\checkers\\readability\\redundant-preprocessor.cpp', '-check-prefixes=CHECK-NOTES', '-implicit-check-not={{note|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/181734
More information about the cfe-commits
mailing list