Index: clang-tidy/readability/NonConstParameterCheck.cpp =================================================================== --- clang-tidy/readability/NonConstParameterCheck.cpp +++ clang-tidy/readability/NonConstParameterCheck.cpp @@ -138,9 +138,20 @@ if (!ParamInfo.CanBeConst) continue; - diag(Par->getLocation(), "pointer parameter '%0' can be pointer to const") - << Par->getName() - << FixItHint::CreateInsertion(Par->getLocStart(), "const "); + auto D = diag(Par->getLocation(), + "pointer parameter '%0' can be pointer to const") + << Par->getName() + << FixItHint::CreateInsertion(Par->getLocStart(), "const "); + + if (const auto *Parent = Par->getParentFunctionOrMethod()) { + if (const auto *F = dyn_cast(Parent)) { + const auto ParDecl = + F->getFirstDecl()->getParamDecl(Par->getFunctionScopeIndex()); + if (Par != ParDecl) + D << ParDecl->getName() + << FixItHint::CreateInsertion(ParDecl->getLocStart(), "const "); + } + } } } Index: test/clang-tidy/readability-non-const-parameter.cpp =================================================================== --- test/clang-tidy/readability-non-const-parameter.cpp +++ test/clang-tidy/readability-non-const-parameter.cpp @@ -277,3 +277,11 @@ int x = *p; } }; + +int declarationFixit(int *i); +// CHECK-FIXES: {{^}}int declarationFixit(const int *i);{{$}} +// CHECK-MESSAGES: :[[@LINE+1]]:27: warning: pointer parameter 'i' can be +int declarationFixit(int *i) { + // CHECK-FIXES: {{^}}int declarationFixit(const int *i) {{{$}} + return *i; +}