LegalizeAdulthood added inline comments. ================ Comment at: test/clang-tidy/readability-non-const-parameter.cpp:116-134 @@ +115,21 @@ + +// CHECK-MESSAGES: :[[@LINE+1]]:18: warning: parameter 'p' can be const +int return1(int *p) { + // CHECK-FIXES: {{^}}int return1(const int *p) {{{$}} + return *p; +} + +// CHECK-MESSAGES: :[[@LINE+1]]:25: warning: parameter 'p' can be const +const int *return2(int *p) { + // CHECK-FIXES: {{^}}const int *return2(const int *p) {{{$}} + return p; +} + +// CHECK-MESSAGES: :[[@LINE+1]]:25: warning: parameter 'p' can be const +const int *return3(int *p) { + // CHECK-FIXES: {{^}}const int *return3(const int *p) {{{$}} + return p + 1; +} + +// CHECK-MESSAGES: :[[@LINE+1]]:27: warning: parameter 'p' can be const +const char *return4(char *p) { ---------------- danielmarjamaki wrote: > rsmith wrote: > > The wording of this warning, and the name of the check, are highly > > misleading. > > > > It's *not* the parameter that can be const, it's the parameter's *pointee*. > I understand. Figuring out a better message is not easy. I and a collegue > brain stormed: > > pointer parameter 'p' could be declared with const 'const int *p' > > pointer parameter 'p' could be pointer to const > > pointer parameter 'p' declaration could be pointer to const > > missing const in pointer parameter 'p' declaration > > declaration of pointer parameter 'p' could be 'const int *p' > > Do you think any of these would be good? > Regarding the name of the check, I can't think of anything better only things that are longer but aren't substantially more clear in revealing the intent of the check. IMO, you don't blindly run clang-tidy checks based on the name, you run them after reading what they do and deciding if you want that transformation or not.
In order of my preference: - pointer parameter 'p' could be pointer to const - declaration of pointer parameter 'p' could be 'const int *p' I might use the word 'can' instead of the world 'could', but that's a very minor quibble. http://reviews.llvm.org/D15332 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits