Lines Matching +full:- +full:p

1 // RUN: %check_clang_tidy %s readability-non-const-parameter %t
6 // the checker only checks if the data can be const-specified.
15 // CHECK-MESSAGES: :[[@LINE+1]]:29: warning: pointer parameter 'last' can be pointer to const [read…
17 // CHECK-FIXES: {{^}}void warn1(int *first, const int *last) {{{$}} in warn1()
20 } // <- last can be const in warn1()
24 void warn2(char *p) { in warn2() argument
26 strcpy1(buf, p); in warn2()
29 // CHECK-MESSAGES: :[[@LINE+1]]:19: warning: pointer parameter 'p' can be
30 void assign1(int *p) { in assign1() argument
31 // CHECK-FIXES: {{^}}void assign1(const int *p) {{{$}} in assign1()
33 q = p; in assign1()
36 // CHECK-MESSAGES: :[[@LINE+1]]:19: warning: pointer parameter 'p' can be
37 void assign2(int *p) { in assign2() argument
38 // CHECK-FIXES: {{^}}void assign2(const int *p) {{{$}} in assign2()
40 q = p + 1; in assign2()
43 void assign3(int *p) { in assign3() argument
44 *p = 0; in assign3()
47 void assign4(int *p) { in assign4() argument
48 *p += 2; in assign4()
51 void assign5(char *p) { in assign5() argument
52 p[0] = 0; in assign5()
55 void assign6(int *p) { in assign6() argument
57 q = p++; in assign6()
60 void assign7(char *p) { in assign7() argument
62 a = b = p; in assign7()
71 unsigned char *p; in assign9() local
72 for (p = str + i; *p;) { in assign9()
77 int i, *p; in assign10() local
78 for (i = 0, p = buf; i < 10; i++, p++) { in assign10()
79 *p = 1; in assign10()
83 // CHECK-MESSAGES: :[[@LINE+1]]:17: warning: pointer parameter 'p' can be
84 void init1(int *p) { in init1() argument
85 // CHECK-FIXES: {{^}}void init1(const int *p) {{{$}} in init1()
86 const int *q = p; in init1()
89 // CHECK-MESSAGES: :[[@LINE+1]]:17: warning: pointer parameter 'p' can be
90 void init2(int *p) { in init2() argument
91 // CHECK-FIXES: {{^}}void init2(const int *p) {{{$}} in init2()
92 const int *q = p + 1; in init2()
95 void init3(int *p) { in init3() argument
96 int *q = p; in init3()
99 void init4(float *p) { in init4() argument
100 int *q = (int *)p; in init4()
103 void init5(int *p) { in init5() argument
104 int *i = p ? p : 0; in init5()
107 void init6(int *p) { in init6() argument
108 int *a[] = {p, p, 0}; in init6()
111 void init7(int *p, int x) { in init7() argument
112 for (int *q = p + x - 1; 0; q++) in init7()
116 // CHECK-MESSAGES: :[[@LINE+1]]:18: warning: pointer parameter 'p' can be
117 int return1(int *p) { in return1() argument
118 // CHECK-FIXES: {{^}}int return1(const int *p) {{{$}} in return1()
119 return *p; in return1()
122 // CHECK-MESSAGES: :[[@LINE+1]]:25: warning: pointer parameter 'p' can be
123 const int *return2(int *p) { in return2() argument
124 // CHECK-FIXES: {{^}}const int *return2(const int *p) {{{$}} in return2()
125 return p; in return2()
128 // CHECK-MESSAGES: :[[@LINE+1]]:25: warning: pointer parameter 'p' can be
129 const int *return3(int *p) { in return3() argument
130 // CHECK-FIXES: {{^}}const int *return3(const int *p) {{{$}} in return3()
131 return p + 1; in return3()
134 // CHECK-MESSAGES: :[[@LINE+1]]:27: warning: pointer parameter 'p' can be
135 const char *return4(char *p) { in return4() argument
136 // CHECK-FIXES: {{^}}const char *return4(const char *p) {{{$}} in return4()
137 return p ? p : ""; in return4()
152 char return8(int *p) { in return8() argument
153 return ++(*p); in return8()
156 void dontwarn1(int *p) { in dontwarn1() argument
157 ++(*p); in dontwarn1()
160 void dontwarn2(int *p) { in dontwarn2() argument
161 (*p)++; in dontwarn2()
164 int dontwarn3(_Atomic(int) * p) { in dontwarn3() argument
165 return *p; in dontwarn3()
168 void callFunction1(char *p) { in callFunction1() argument
169 strcpy1(p, "abc"); in callFunction1()
172 void callFunction2(char *p) { in callFunction2() argument
173 strcpy1(&p[0], "abc"); in callFunction2()
176 void callFunction3(char *p) { in callFunction3() argument
177 strcpy1(p + 2, "abc"); in callFunction3()
180 char *callFunction4(char *p) { in callFunction4() argument
181 return strcpy1(p, "abc"); in callFunction4()
189 void f6(int **p);
190 void callFunction6(int *p) { f6(&p); } in callFunction6() argument
194 void callFunction7(int *p) { in callFunction7() argument
195 f7((t){p}); in callFunction7()
199 void callFunction8(int *p) { in callFunction8() argument
200 f8(*p); in callFunction8()
209 // CHECK-MESSAGES: :[[@LINE+1]]:27: warning: pointer parameter 'p' can be
210 int functionpointer2(int *p) { in functionpointer2() argument
211 return *p; in functionpointer2()
214 int (*fp)(int *) = functionpointer2; // <- the parameter 'p' can't be const in use_functionpointer2()
223 *(xy->x) = 0; in recordpointer()
232 // CHECK-MESSAGES: :[[@LINE+1]]:30: warning: pointer parameter 'x' can be pointer to const
234 // CHECK-FIXES: {{^}}void recordInitListDiag(const int *x) {{{$}} in recordInitListDiag()
238 // CHECK-MESSAGES: :[[@LINE+1]]:35: warning: pointer parameter 'x' can be pointer to const
240 // CHECK-FIXES: {{^}}void recordInitListAliasDiag(const int *x) {{{$}} in recordInitListAliasDiag()
246 C(int *p) : p(p) {} in C() argument
249 int *p; member in C
254 // CHECK-MESSAGES: :[[@LINE+1]]:11: warning: pointer parameter 'p' can be
255 C2(int *p) : p(p) {} in C2() argument
256 // CHECK-FIXES: {{^}} C2(const int *p) : p(p) {}{{$}}
259 const int *p; member in C2
262 void tempObject(int *p) { in tempObject() argument
263 C c(p); in tempObject()
273 // CHECK-MESSAGES: :[[@LINE+1]]:21: warning: pointer parameter 'p' can be
274 void doStuff(int *p) { in doStuff() argument
275 // CHECK-FIXES: {{^}} void doStuff(const int *p) {{{$}} in doStuff()
276 x = *p; in doStuff()
286 virtual void doStuff(int *p) { in doStuff() argument
287 int x = *p; in doStuff()
294 void doStuff(int *p) override { in doStuff() argument
295 int x = *p; in doStuff()
300 // CHECK-FIXES: {{^}}extern char foo(const char *s); // 1{{$}}
301 // CHECK-MESSAGES: :[[@LINE+1]]:16: warning: pointer parameter 's' can be
303 // CHECK-FIXES: {{^}}char foo(const char *s) {{{$}} in foo()
307 // CHECK-FIXES: {{^}}char foo(const char *s); // 2{{$}}
309 void lvalueReference(int *p) { in lvalueReference() argument
310 // CHECK-MESSAGES-NOT: warning: pointer parameter 'p' can be in lvalueReference()
311 int &x = *p; in lvalueReference()
314 // CHECK-MESSAGES: :[[@LINE+1]]:32: warning: pointer parameter 'p' can be
315 void constLValueReference(int *p) { in constLValueReference() argument
316 // CHECK-FIXES: {{^}}void constLValueReference(const int *p) {{{$}} in constLValueReference()
317 const int &x = *p; in constLValueReference()
320 void lambdaLVRef(int *p) { in lambdaLVRef() argument
321 // CHECK-MESSAGES-NOT: warning: pointer parameter 'p' can be in lambdaLVRef()
323 int &x = *p; in lambdaLVRef()
327 // CHECK-MESSAGES: :[[@LINE+1]]:28: warning: pointer parameter 'p' can be
328 void lambdaConstLVRef(int *p) { in lambdaConstLVRef() argument
329 // CHECK-FIXES: {{^}}void lambdaConstLVRef(const int *p) {{{$}} in lambdaConstLVRef()
331 const int &x = *p; in lambdaConstLVRef()
340 void constructLVRef(int *p) { in constructLVRef() argument
341 // CHECK-MESSAGES-NOT: warning: pointer parameter 'p' can be in constructLVRef()
342 Temp1 t(*p); in constructLVRef()