[clang-tools-extra] [clang-tidy] Fix false positive for generic lambda parameters in readability-non-const-parameter (PR #179051)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 31 09:53:17 PST 2026
github-actions[bot] wrote:
<!--PREMERGE ADVISOR COMMENT: Windows-->
# :window: Windows x64 Test Results
* 3034 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/non-const-parameter.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\non-const-parameter.cpp readability-non-const-parameter C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.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\readability\non-const-parameter.cpp' readability-non-const-parameter 'C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.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\\readability\\Output\\non-const-parameter.cpp.tmp.cpp', '-fix', '--checks=-*,readability-non-const-parameter', '--config={}', '--', '-std=c++11', '-nostdinc++']...
# | ------------------------ clang-tidy output -----------------------
# | 21 warnings generated.
# |
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:16:29: warning: pointer parameter 'last' can be pointer to const [readability-non-const-parameter]
# | 16 | void warn1(int *first, int *last) {
# | | ^
# | | const
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:16:24: note: FIX-IT applied suggested code changes
# | 16 | void warn1(int *first, int *last) {
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:30:19: warning: pointer parameter 'p' can be pointer to const [readability-non-const-parameter]
# | 30 | void assign1(int *p) {
# | | ^
# | | const
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:30:14: note: FIX-IT applied suggested code changes
# | 30 | void assign1(int *p) {
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:37:19: warning: pointer parameter 'p' can be pointer to const [readability-non-const-parameter]
# | 37 | void assign2(int *p) {
# | | ^
# | | const
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:37:14: note: FIX-IT applied suggested code changes
# | 37 | void assign2(int *p) {
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:84:17: warning: pointer parameter 'p' can be pointer to const [readability-non-const-parameter]
# | 84 | void init1(int *p) {
# | | ^
# | | const
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:84:12: note: FIX-IT applied suggested code changes
# | 84 | void init1(int *p) {
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:90:17: warning: pointer parameter 'p' can be pointer to const [readability-non-const-parameter]
# | 90 | void init2(int *p) {
# | | ^
# | | const
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:90:12: note: FIX-IT applied suggested code changes
# | 90 | void init2(int *p) {
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:117:18: warning: pointer parameter 'p' can be pointer to const [readability-non-const-parameter]
# | 117 | int return1(int *p) {
# | | ^
# | | const
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:117:13: note: FIX-IT applied suggested code changes
# | 117 | int return1(int *p) {
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:123:25: warning: pointer parameter 'p' can be pointer to const [readability-non-const-parameter]
# | 123 | const int *return2(int *p) {
# | | ^
# | | const
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:123:20: note: FIX-IT applied suggested code changes
# | 123 | const int *return2(int *p) {
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:129:25: warning: pointer parameter 'p' can be pointer to const [readability-non-const-parameter]
# | 129 | const int *return3(int *p) {
# | | ^
# | | const
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:129:20: note: FIX-IT applied suggested code changes
# | 129 | const int *return3(int *p) {
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:135:27: warning: pointer parameter 'p' can be pointer to const [readability-non-const-parameter]
# | 135 | const char *return4(char *p) {
# | | ^
# | | const
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:135:21: note: FIX-IT applied suggested code changes
# | 135 | const char *return4(char *p) {
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:210:27: warning: pointer parameter 'p' can be pointer to const [readability-non-const-parameter]
# | 210 | int functionpointer2(int *p) {
# | | ^
# | | const
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:210:22: note: FIX-IT applied suggested code changes
# | 210 | int functionpointer2(int *p) {
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:233:30: warning: pointer parameter 'x' can be pointer to const [readability-non-const-parameter]
# | 233 | void recordInitListDiag(int *x) {
# | | ^
# | | const
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:233:25: note: FIX-IT applied suggested code changes
# | 233 | void recordInitListDiag(int *x) {
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:239:35: warning: pointer parameter 'x' can be pointer to const [readability-non-const-parameter]
# | 239 | void recordInitListAliasDiag(int *x) {
# | | ^
# | | const
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:239:30: note: FIX-IT applied suggested code changes
# | 239 | void recordInitListAliasDiag(int *x) {
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:255:11: warning: pointer parameter 'p' can be pointer to const [readability-non-const-parameter]
# | 255 | C2(int *p) : p(p) {}
# | | ^
# | | const
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:255:6: note: FIX-IT applied suggested code changes
# | 255 | C2(int *p) : p(p) {}
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:274:21: warning: pointer parameter 'p' can be pointer to const [readability-non-const-parameter]
# | 274 | void doStuff(int *p) {
# | | ^
# | | const
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:274:16: note: FIX-IT applied suggested code changes
# | 274 | void doStuff(int *p) {
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:302:16: warning: pointer parameter 's' can be pointer to const [readability-non-const-parameter]
# | 299 | extern char foo(char *s); // 1
# | |
# | | const
# | 300 | //
# | 301 | //
# | 302 | char foo(char *s) {
# | | ^
# | | const
# | 303 | //
# | 304 | return *s;
# | 305 | }
# | 306 | char foo(char *s); // 2
# | |
# | | const
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:299:17: note: FIX-IT applied suggested code changes
# | 299 | extern char foo(char *s); // 1
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:302:10: note: FIX-IT applied suggested code changes
# | 302 | char foo(char *s) {
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:306:10: note: FIX-IT applied suggested code changes
# | 306 | char foo(char *s); // 2
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:315:32: warning: pointer parameter 'p' can be pointer to const [readability-non-const-parameter]
# | 315 | void constLValueReference(int *p) {
# | | ^
# | | const
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:315:27: note: FIX-IT applied suggested code changes
# | 315 | void constLValueReference(int *p) {
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:328:28: warning: pointer parameter 'p' can be pointer to const [readability-non-const-parameter]
# | 328 | void lambdaConstLVRef(int *p) {
# | | ^
# | | const
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:328:23: note: FIX-IT applied suggested code changes
# | 328 | void lambdaConstLVRef(int *p) {
# | | ^
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:375:32: warning: pointer parameter 'p' can be pointer to const [readability-non-const-parameter]
# | 375 | auto regularLambda = [](int *p) {
# | | ^
# | | const
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:375:27: note: FIX-IT applied suggested code changes
# | clang-tidy applied 20 of 20 suggested fixes.
# |
# | 375 | auto regularLambda = [](int *p) {
# | | ^
# | Suppressed 3 warnings (3 with check filters).
# |
# |
# | ------------------------------------------------------------------
# | diff -u C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.orig C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp failed:
# | --- C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.orig 2026-01-31 17:51:56.315102400 +0000
# | +++ C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp 2026-01-31 17:51:56.375075100 +0000
# | @@ -13,7 +13,7 @@
# | unsigned my_strlen(const char *buf);
# |
# |
# |
# | //
# |
# | -void warn1(int *first, int *last) {
# |
# | +void warn1(int *first, const int *last) {
# |
# | //
# |
# | *first = 0;
# |
# | if (first < last) {
# |
# | @@ -27,14 +27,14 @@
# | }
# |
# |
# |
# | //
# |
# | -void assign1(int *p) {
# |
# | +void assign1(const int *p) {
# |
# | //
# |
# | const int *q;
# |
# | q = p;
# |
# | }
# |
# |
# |
# | //
# |
# | -void assign2(int *p) {
# |
# | +void assign2(const int *p) {
# |
# | //
# |
# | const int *q;
# |
# | q = p + 1;
# |
# | @@ -81,13 +81,13 @@
# | }
# |
# |
# |
# | //
# |
# | -void init1(int *p) {
# |
# | +void init1(const int *p) {
# |
# | //
# |
# | const int *q = p;
# |
# | }
# |
# |
# |
# | //
# |
# | -void init2(int *p) {
# |
# | +void init2(const int *p) {
# |
# | //
# |
# | const int *q = p + 1;
# |
# | }
# |
# | @@ -114,25 +114,25 @@
# | }
# |
# |
# |
# | //
# |
# | -int return1(int *p) {
# |
# | +int return1(const int *p) {
# |
# | //
# |
# | return *p;
# |
# | }
# |
# |
# |
# | //
# |
# | -const int *return2(int *p) {
# |
# | +const int *return2(const int *p) {
# |
# | //
# |
# | return p;
# |
# | }
# |
# |
# |
# | //
# |
# | -const int *return3(int *p) {
# |
# | +const int *return3(const int *p) {
# |
# | //
# |
# | return p + 1;
# |
# | }
# |
# |
# |
# | //
# |
# | -const char *return4(char *p) {
# |
# | +const char *return4(const char *p) {
# |
# | //
# |
# | return p ? p : "";
# |
# | }
# |
# | @@ -207,7 +207,7 @@
# |
# |
# | // TODO: This is a false positive.
# |
# | //
# |
# | -int functionpointer2(int *p) {
# |
# | +int functionpointer2(const int *p) {
# |
# | return *p;
# |
# | }
# |
# | void use_functionpointer2() {
# |
# | @@ -230,13 +230,13 @@
# | int const *x;
# |
# | };
# |
# | //
# |
# | -void recordInitListDiag(int *x) {
# |
# | +void recordInitListDiag(const int *x) {
# |
# | //
# |
# | XYConst xy = {x};
# |
# | }
# |
# | typedef XYConst XYConstAlias;
# |
# | //
# |
# | -void recordInitListAliasDiag(int *x) {
# |
# | +void recordInitListAliasDiag(const int *x) {
# |
# | //
# |
# | XYConstAlias xy = {x};
# |
# | }
# |
# | @@ -252,7 +252,7 @@
# | class C2 {
# |
# | public:
# |
# | //
# |
# | - C2(int *p) : p(p) {}
# |
# | + C2(const int *p) : p(p) {}
# |
# | //
# |
# |
# |
# | private:
# |
# | @@ -271,7 +271,7 @@
# | class Warn {
# |
# | public:
# |
# | //
# |
# | - void doStuff(int *p) {
# |
# | + void doStuff(const int *p) {
# |
# | //
# |
# | x = *p;
# |
# | }
# |
# | @@ -296,14 +296,14 @@
# | }
# |
# | };
# |
# |
# |
# | -extern char foo(char *s); // 1
# |
# | +extern char foo(const char *s); // 1
# |
# | //
# |
# | //
# |
# | -char foo(char *s) {
# |
# | +char foo(const char *s) {
# |
# | //
# |
# | return *s;
# |
# | }
# |
# | -char foo(char *s); // 2
# |
# | +char foo(const char *s); // 2
# |
# | //
# |
# |
# |
# | void lvalueReference(int *p) {
# |
# | @@ -312,7 +312,7 @@
# | }
# |
# |
# |
# | //
# |
# | -void constLValueReference(int *p) {
# |
# | +void constLValueReference(const int *p) {
# |
# | //
# |
# | const int &x = *p;
# |
# | }
# |
# | @@ -325,7 +325,7 @@
# | }
# |
# |
# |
# | //
# |
# | -void lambdaConstLVRef(int *p) {
# |
# | +void lambdaConstLVRef(const int *p) {
# |
# | //
# |
# | auto foo = [&]() {
# |
# | const int &x = *p;
# |
# | @@ -372,7 +372,7 @@
# | };
# |
# |
# |
# | //
# |
# | - auto regularLambda = [](int *p) {
# |
# | + auto regularLambda = [](const int *p) {
# |
# | //
# |
# | int x = *p;
# |
# | };
# |
# |
# | ------------------------------ Fixes -----------------------------
# | --- C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.orig 2026-01-31 17:51:56.315102400 +0000
# | +++ C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp 2026-01-31 17:51:56.375075100 +0000
# | @@ -13,7 +13,7 @@
# | unsigned my_strlen(const char *buf);
# |
# |
# |
# | //
# |
# | -void warn1(int *first, int *last) {
# |
# | +void warn1(int *first, const int *last) {
# |
# | //
# |
# | *first = 0;
# |
# | if (first < last) {
# |
# | @@ -27,14 +27,14 @@
# | }
# |
# |
# |
# | //
# |
# | -void assign1(int *p) {
# |
# | +void assign1(const int *p) {
# |
# | //
# |
# | const int *q;
# |
# | q = p;
# |
# | }
# |
# |
# |
# | //
# |
# | -void assign2(int *p) {
# |
# | +void assign2(const int *p) {
# |
# | //
# |
# | const int *q;
# |
# | q = p + 1;
# |
# | @@ -81,13 +81,13 @@
# | }
# |
# |
# |
# | //
# |
# | -void init1(int *p) {
# |
# | +void init1(const int *p) {
# |
# | //
# |
# | const int *q = p;
# |
# | }
# |
# |
# |
# | //
# |
# | -void init2(int *p) {
# |
# | +void init2(const int *p) {
# |
# | //
# |
# | const int *q = p + 1;
# |
# | }
# |
# | @@ -114,25 +114,25 @@
# | }
# |
# |
# |
# | //
# |
# | -int return1(int *p) {
# |
# | +int return1(const int *p) {
# |
# | //
# |
# | return *p;
# |
# | }
# |
# |
# |
# | //
# |
# | -const int *return2(int *p) {
# |
# | +const int *return2(const int *p) {
# |
# | //
# |
# | return p;
# |
# | }
# |
# |
# |
# | //
# |
# | -const int *return3(int *p) {
# |
# | +const int *return3(const int *p) {
# |
# | //
# |
# | return p + 1;
# |
# | }
# |
# |
# |
# | //
# |
# | -const char *return4(char *p) {
# |
# | +const char *return4(const char *p) {
# |
# | //
# |
# | return p ? p : "";
# |
# | }
# |
# | @@ -207,7 +207,7 @@
# |
# |
# | // TODO: This is a false positive.
# |
# | //
# |
# | -int functionpointer2(int *p) {
# |
# | +int functionpointer2(const int *p) {
# |
# | return *p;
# |
# | }
# |
# | void use_functionpointer2() {
# |
# | @@ -230,13 +230,13 @@
# | int const *x;
# |
# | };
# |
# | //
# |
# | -void recordInitListDiag(int *x) {
# |
# | +void recordInitListDiag(const int *x) {
# |
# | //
# |
# | XYConst xy = {x};
# |
# | }
# |
# | typedef XYConst XYConstAlias;
# |
# | //
# |
# | -void recordInitListAliasDiag(int *x) {
# |
# | +void recordInitListAliasDiag(const int *x) {
# |
# | //
# |
# | XYConstAlias xy = {x};
# |
# | }
# |
# | @@ -252,7 +252,7 @@
# | class C2 {
# |
# | public:
# |
# | //
# |
# | - C2(int *p) : p(p) {}
# |
# | + C2(const int *p) : p(p) {}
# |
# | //
# |
# |
# |
# | private:
# |
# | @@ -271,7 +271,7 @@
# | class Warn {
# |
# | public:
# |
# | //
# |
# | - void doStuff(int *p) {
# |
# | + void doStuff(const int *p) {
# |
# | //
# |
# | x = *p;
# |
# | }
# |
# | @@ -296,14 +296,14 @@
# | }
# |
# | };
# |
# |
# |
# | -extern char foo(char *s); // 1
# |
# | +extern char foo(const char *s); // 1
# |
# | //
# |
# | //
# |
# | -char foo(char *s) {
# |
# | +char foo(const char *s) {
# |
# | //
# |
# | return *s;
# |
# | }
# |
# | -char foo(char *s); // 2
# |
# | +char foo(const char *s); // 2
# |
# | //
# |
# |
# |
# | void lvalueReference(int *p) {
# |
# | @@ -312,7 +312,7 @@
# | }
# |
# |
# |
# | //
# |
# | -void constLValueReference(int *p) {
# |
# | +void constLValueReference(const int *p) {
# |
# | //
# |
# | const int &x = *p;
# |
# | }
# |
# | @@ -325,7 +325,7 @@
# | }
# |
# |
# |
# | //
# |
# | -void lambdaConstLVRef(int *p) {
# |
# | +void lambdaConstLVRef(const int *p) {
# |
# | //
# |
# | auto foo = [&]() {
# |
# | const int &x = *p;
# |
# | @@ -372,7 +372,7 @@
# | };
# |
# |
# |
# | //
# |
# | - auto regularLambda = [](int *p) {
# |
# | + auto regularLambda = [](const int *p) {
# |
# | //
# |
# | int x = *p;
# |
# | };
# |
# |
# | ------------------------------------------------------------------
# | FileCheck -input-file=C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp.msg C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\readability\non-const-parameter.cpp -check-prefixes=CHECK-MESSAGES -implicit-check-not={{warning|error}}: failed:
# | C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\readability\non-const-parameter.cpp:374:21: error: CHECK-MESSAGES: expected string not found in input
# |
# | // CHECK-MESSAGES: :[[@LINE+1]]:31: warning: pointer parameter 'p' can be pointer to const
# |
# | ^
# |
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp.msg:131:187: note: scanning from here
# |
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:328:28: warning: pointer parameter 'p' can be pointer to const [readability-non-const-parameter]
# |
# | ^
# |
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp.msg:131:187: note: with "@LINE+1" equal to "375"
# |
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:328:28: warning: pointer parameter 'p' can be pointer to const [readability-non-const-parameter]
# |
# | ^
# |
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp.msg:138:144: note: possible intended match here
# |
# | C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:375:32: warning: pointer parameter 'p' can be pointer to const [readability-non-const-parameter]
# |
# | ^
# |
# |
# |
# | Input file: C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp.msg
# |
# | Check file: C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\checkers\readability\non-const-parameter.cpp
# |
# |
# |
# | -dump-input=help explains the following input dump.
# |
# |
# |
# | Input was:
# |
# | <<<<<<
# |
# | .
# |
# | .
# |
# | .
# |
# | 126: | ^
# |
# | 127: | const
# |
# | 128: C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:315:27: note: FIX-IT applied suggested code changes
# |
# | 129: 315 | void constLValueReference(int *p) {
# |
# | 130: | ^
# |
# | 131: C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:328:28: warning: pointer parameter 'p' can be pointer to const [readability-non-const-parameter]
# |
# | check:374'0 X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
# |
# | check:374'1 with "@LINE+1" equal to "375"
# |
# | 132: 328 | void lambdaConstLVRef(int *p) {
# |
# | check:374'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
# | 133: | ^
# |
# | check:374'0 ~~~~~
# |
# | 134: | const
# |
# | check:374'0 ~~~~~~~~~~
# |
# | 135: C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:328:23: note: FIX-IT applied suggested code changes
# |
# | check:374'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
# | 136: 328 | void lambdaConstLVRef(int *p) {
# |
# | check:374'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
# | 137: | ^
# |
# | check:374'0 ~~~~~
# |
# | 138: C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:375:32: warning: pointer parameter 'p' can be pointer to const [readability-non-const-parameter]
# |
# | check:374'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
# | check:374'2 ? possible intended match
# |
# | 139: 375 | auto regularLambda = [](int *p) {
# |
# | check:374'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
# | 140: | ^
# |
# | check:374'0 ~~~~~
# |
# | 141: | const
# |
# | check:374'0 ~~~~~~~~~~
# |
# | 142: C:\_work\llvm-project\llvm-project\build\tools\clang\tools\extra\test\clang-tidy\checkers\readability\Output\non-const-parameter.cpp.tmp.cpp:375:27: note: FIX-IT applied suggested code changes
# |
# | check:374'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
# | 143: clang-tidy applied 20 of 20 suggested fixes.
# |
# |
# | check:374'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 413, in <module>
# | main()
# | File "C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\check_clang_tidy.py", line 409, 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 312, in run
# | self.check_messages(clang_tidy_output)
# | File "C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\check_clang_tidy.py", line 273, in check_messages
# | try_run(
# | File "C:\_work\llvm-project\llvm-project\clang-tools-extra\test\clang-tidy\check_clang_tidy.py", line 63, 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\\non-const-parameter.cpp.tmp.cpp.msg', 'C:\\_work\\llvm-project\\llvm-project\\clang-tools-extra\\test\\clang-tidy\\checkers\\readability\\non-const-parameter.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/179051
More information about the cfe-commits
mailing list