1 .. title:: clang-tidy - readability-non-const-parameter
3 readability-non-const-parameter
4 ===============================
6 The check finds function parameters of a pointer type that could be changed to
7 point to a constant type instead.
9 When ``const`` is used properly, many mistakes can be avoided. Advantages when
10 using ``const`` properly:
12 - prevent unintentional modification of data;
14 - get additional warnings such as using uninitialized data;
16 - make it easier for developers to see possible side effects.
18 This check is not strict about constness, it only warns when the constness will
19 make the function interface safer.
23 // warning here; the declaration "const char *p" would make the function
29 // no warning; the declaration could be more const "const int * const p" but
30 // that does not make the function interface safer.
31 int f2(const int *p) {
35 // no warning; making x const does not make the function interface safer
40 // no warning; Technically, *p can be const ("const struct S *p"). But making
41 // *p const could be misleading. People might think that it's safe to pass
42 // const data to this function.
43 struct S { int *a; int *b; };
48 // no warning; p is referenced by an lvalue.